Restrict spam email M2 Registertation

At the moment, the users can register with the same emails by adding plus(+) Sign to their same email ID, eg:, etc

Would like to know if there is any quick workaround to prevent users from creating such registrations via the Register form of M2

  • Nithin
    • Support Wizard

    Hello Dario,

    I'm bringing this query into our developers attention, so that he could give a closer look, and see whether there is any quick working to make this work. Please do note that developers work round the clock with many critical issues, and hence have a slow response time. Either myself, or the developer will keep you posted.

    Kind Regards,

  • Ivan
    • Developer

    Hi Dario !

    You could try adding the following snippet in a MU plugin ( more info about MU plugins is here )

    function wpmu_m2_restrict_email( $validation_errors, $obj ) {
    	if ( empty( $validation_errors->errors['emailnotvalid'] ) && ( empty( $obj->email ) || false !== strpos( $obj->email, '+' ) ) ) {
    			__( 'The email address is not valid, sorry.', 'membership2' )
    	return $validation_errors;
    add_filter( 'ms_model_membership_create_new_user_validation_errors', 'wpmu_m2_restrict_email', 10, 2 );


  • Felix
    • WPMU DEV Initiate

    Hello Ivan,

    Thanks for your message.

    Where exactly do I have to insert the code snippet? In which MU plug-in? Do I have to insert it in the function.php or do I have to install a new plug-in? Or do I paste it in some files of the Membership plug-in?


  • Adam Czajczyk
    • Support Gorilla

    Hi Dario

    I hope you're well today!

    "MU Plugin" stands for "must use" plugin and it's a special kind of WordPress plugin that gets executed each time and doesn't require any activation/installation (and can't also be disabled via the dashboard).

    To use the code that Ivan shared, please follow these steps:

    1. create an empty file with a .php extension (e.g. "stop-membership-spam-registration.php")
    2. Open that file with some "clear text" editor (such as e.g. Notepad++, Sublime or similar)
    3. Copy and paste Ivan's code into it and save the file
    4. Using FTP or cPanel's File Manager upload the file to the


    folder of you site's WP install on the server.

    If there's no "mu-plugins" folder inside "wp-content" folder, simply create it. Please note: it has to be "/wp-content/mu-plugins/" and not '/wp-content/plugins/mu-plugins" :slight_smile:

    Nothing more needs to be done and the code will automatically get executed.

    Best regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.