How to prevent spam users registering even with registration disabled

This code should make it impossible to add a new user, as long as it is being added with wp_insert_user().

add_filter( 'pre_user_login', '__return_false' );

That filter is applied to the user’s login name before it is saved. If the result is empty, the user isn’t added. This will make it so the login will always be empty, so it will be impossible to add new users, even from the administration panels.

Leave a Comment