2

I'm dealing with fake user registrations on my site. Since i'm using WooCommerce, i have a custom signup page which will generate users with "customer" as the user role. However, all of the fake users are registering through wp-login.php, which will generate a user with the "subscriber" role.

Is it possible to somehow disable the user generation process(probably inside wp_insert_user()) if it tries to signup a user with the role set to subscriber? The closest action i could find is user_register, which triggers immediately after the user has been created, so i could delete the user if the role is subscriber, but i would like to do this before the user is even created.

Also most of the user data is filtered, but not the user role:(

1 Answer 1

1

There might be more elegant way to do it, but from quick look at the code it seems quite easy to simply override the relevant option on login page:

add_action( 'login_init', function () {
    add_action( 'pre_option_users_can_register', '__return_null' );
} );

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.