Is it possible to remove this action? (as it’s added just before it’s called)

In wp-signup.php there are these lines:

add_action( 'wp_head', 'wpmu_signup_stylesheet' );
get_header();

I need to remove wpmu_signup_stylesheet from the wp_head action, but I seem to be struggling, I assume it is because the action is being called straight after.

Read More

Here is what I’ve tried from a plugin:

// Called from an action that is added with:
// add_action('wp_head', array($this, 'remove_signup_style', 11));
remove_action( 'wp_head', 'wpmu_signup_stylesheet');

Related posts

Leave a Reply

3 comments

  1. The action is not right after actually. There is get_header() call, then get_header action and then locating and loading template file that has wp_head() in it.

    I try not to mess with removing things from inside of same hook you are at, so in this case I’d (ab)use that get_header action to hook function that will remove what you don’t want from later wp_head.

  2. Thanks for the tip @Rarst! Working code below.

    //Remove the css injected into wp_head for the wp-signup.php form
    add_action('get_header', 'remove_wpmu_signup_styles');
    function remove_wpmu_signup_styles () {
        remove_action('wp_head', 'wpmu_signup_stylesheet');
    }
    
  3. Try adding a priority:

    remove_action( 'wp_head', 'wpmu_signup_stylesheet', 11 );
    

    p.s. is the add_action() call really placed before get_header(), or is it placed before wp_head()? I’m not sure it really matters, so long as wp_head() is included in header.php; but that’s just an unusual place to add an add_action() call.