Intercept loading of a certain page

One way to approach this is to intercept the page load with the template_redirect action and test user status before rending the login page. Based on user status you could redirect to another page instead of loading the original page content. function wpse_is_user_good_enough() { if ( ! is_page( ‘your-login-page-slug-here’ ) ) { return; // Not … Read more

Show full post instead of excerpt

You should use this (because the content saved in the post is unfiltered): echo apply_filters( ‘the_content’, $post->post_content ); However, be advised that you should not alter code of plugins or themes that are not created by you. If that plugin is updated, your altered code is probably gone. For themes, you could create a child … Read more

How can I filter the comment action links so that I can display the actions links based on user capabilities?

Yes, there is a hook you can use to filter the action links: comment_row_actions. E.g. add_filter( ‘comment_row_actions’, ‘my_comment_row_actions’, 10, 2 ); function my_comment_row_actions( $actions, $comment ) { // Filter the actions by user role. $roles = (array) wp_get_current_user()->roles; if ( in_array( ‘administrator’, $roles ) ) { $actions[‘foo’] = ‘<a href=”#”>Foo action</a>’; } // Filter the … Read more

style_loader_tag not changing stylesheet to preload

I tested your code and it seems to work fine, my guess is that your $targetHanldes containes the wrong handles. Best option would be to see what $html and $handle contain and that way you could add them to the haystack. But for now try this instead $targetHanldes = array(‘flexible-shipping-notices’, ‘animate’); Again this is pure … Read more

Is it likely that do_action will have unexpected results?

In the described scenario, f1 was added and it was indicated it only takes a single parameter, so only one parameter is provided ( the first ). So f1 is never called with more than one parameter. However, it is possible to make a mistake, if you call add_action and declare that f1 can receive … Read more

Woocommerce : Add name filed of checkout page to buyers wordpress display name

The second part of the problem is solved by putting this code into theme’s functions.php file : // First name as default display name add_action( ‘profile_update’, ‘set_display_name’, 10 ); function set_display_name( $user_id ) { $data = get_userdata( $user_id ); if($data->first_name) { remove_action( ‘profile_update’, ‘set_display_name’, 10 ); // profile_update is called by wp_update_user, so we need … Read more

Set cors header for ajax requests

The send_headers hook is not fired during an (admin) AJAX request (because there is no “main WordPress query”, so the wp() function doesn’t run and therefore that hook doesn’t get fired either), hence if you want to send the CORS header (and any other headers), then just call header() from within your AJAX callback, like … Read more