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