Blocking Members

Hi there,

Is there a way to block certain emails from being able to rejoin?

Hi Jason.

s2Member doesn’t have a blacklist. It has a feature to prevent certain emails, but probably not what you’re looking for. WP Admin > s2Member > General > Registration/Profile Fields & Options > Force Personal Emails

You can write a custom filter to do that, though. I’ll check later to see if I still have such code. Just replying now to remind myself.

Try this as an mu-plugin. You need to be using a Stripe or PayPal form.

<?php
function kts_blacklist_emails( $response, $form, $s ) {

    # Create a blacklist
    $blacklist = array(
	'nogood@gmail.com',
	'noggod@yahoo.com',
	'nogood@hotmail.com'
    );

    if ( !$response ) { // No other errors produced by s2Member itself

        # Apply to new registrations, and to any new user completing checkout
        if ( $form === 'registration' || !is_user_logged_in() ) {

            if ( isset( $s['email'] ) && in_array( $s['email'], $blacklist ) ) {
                $response = array(
                    'error'    => TRUE, // This is an error.
                    'response' => _x( 'ERROR: You cannot use this email account.', 's2member-front', 's2member' )
	        );
	    }
        }
    }
    return $response;
}
add_filter( 'ws_plugin__s2member_pro_paypal_form_submission_validation_response', 'kts_blacklist_emails', 10, 3 );
add_filter( 'ws_plugin__s2member_pro_stripe_form_submission_validation_response', 'kts_blacklist_emails', 10, 3 );
3 Likes