skip to Main Content

i what to remove this filter:

wp-includes/user.php line 2158 function wp_insert_user

$user_nicename = apply_filters( 'pre_user_nicename', $user_nicename );

if ( mb_strlen( $user_nicename ) > 50 ) {
return new WP_Error( 'user_nicename_too_long', __( 'Nicename may not be longer than 50 characters.' ) );
}

I wrote this code but it doesn’t remove the filter:

remove_filter('pre_user_nicename', 'wp_insert_user');

what is the problem?

2

Answers


  1. Chosen as BEST ANSWER

    The problem is not the filter. The problem is that this condition must be removed

    if ( mb_strlen( $user_nicename ) > 50 ) { return new WP_Error( 'user_nicename_too_long', __( 'Nicename may not be longer than 50 characters.' ) ); }


  2. That’s not how remove_filter() works: the second parameter would be a callback that’s been applied to the filter, not the name of the function that contains the function.

    If you want to remove all callbacks applied to a particular filter, you can use remove_all_filters() (untested):

    remove_all_filters( 'pre_user_nicename' );
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search