2

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.

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');

3 Answers 3

4

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.

1
  • Many thanks, just changed the hook of the function that called remove_action to get_header.
    – Dunhamzzz
    Jul 22, 2011 at 13:49
0

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');
}
-1

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.

3
  • The priority arg passed to remove_action() has to match the one from add_action().
    – scribu
    Jul 22, 2011 at 13:41
  • I always seem to forget that! :) Jul 22, 2011 at 13:43
  • Yeah those two lines are exactly as that in wp-signup.php. As per the docs you can only remove an action if the priorty is the same, the weird thing is that remove_Action actually returns true yet the action is still being ran.
    – Dunhamzzz
    Jul 22, 2011 at 13:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.