• Resolved ddas

    (@ddas)


    Thanks for your excellent plug-in! I use NUA in tandem with MemberPress because I run a membership site. I would like to be able to have new users who sign up for specific membership levels bypass NUA completely. Is there a way to do this? How complicated would it be to add?

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Mirza Hamza

    (@hamza1010)

    Hi @ddas,

    Thanks for contacting us,

    I hope you are doing well, To escalate your case, please create a ticket on our official website so that we can connect you directly with our Technical team.

    Looking forward to getting your issue resolved.

    Thanks & Regards

    WP Experts Support Team

    Hi – did this get resolved? I’m looking to do this also – how do I bypass NUA for specific Memberpress membership levels?

    Give this a try (instructions are in the comment below the code): https://gist.github.com/cartpauj/15a808ff34109617af7449cea4a89130

    Plugin Support Mirza Hamza

    (@hamza1010)

    Hi @nathardwick,

    Please use this code in the child theme functions.php file, when a new membership creates with a specific membership level NUA will auto-approve it and send approved and login instructions emails to users.

    if ( in_array( 'new-user-approve/new-user-approve.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
    
    add_filter('nua_disable_welcome_email', 'stop_nua_welcome_email', 10,2);
    
    function stop_nua_welcome_email($option, $user_id) {
    
    		if(in_array($user_id , nua_bypass_new_user())) {
    
    			return true;
    		}
    		return false;
    }
    
    add_filter('new_user_approve_default_status', 'nua_change_user_status', 10,2);
    
    function nua_change_user_status($status, $user_id) {
    
    	if(in_array($user_id , nua_bypass_new_user())) {
    		return 'approved';
    	}
    	return $status;
    
    }
    
    add_action('user_register', 'nua_send_approval_email',10); 
    function nua_send_approval_email( $user_id) {
    
    	if(in_array($user_id , nua_bypass_new_user()) ) {
    
    		$user = new WP_User( $user_id );
            wp_cache_delete( $user->ID, 'users' );
            wp_cache_delete( $user->data->user_login, 'userlogins' );
            // send email to user telling of approval
            $user_login = stripslashes( $user->data->user_login );
            $user_email = stripslashes( $user->data->user_email );
            // format the message
            $message = nua_default_approve_user_message();
            $message = nua_do_email_tags( $message, array(
                'context'    => 'approve_user',
                'user'       => $user,
                'user_login' => $user_login,
                'user_email' => $user_email,
            ) );
            $message = apply_filters( 'new_user_approve_approve_user_message', $message, $user );
            $subject = sprintf( __( '[%s] Registration Approved', 'new-user-approve' ), get_option( 'blogname' ) );
            $subject = apply_filters( 'new_user_approve_approve_user_subject', $subject );
            // send the mail
            wp_mail(
                $user_email,
                $subject,
                $message,
                nua_email_message_headers()
            );
            update_user_meta( $user->ID, 'pw_user_status', 'approved' );
    		add_filter( 'new_user_approve_pending_message', 'nua_auto_approve_messages');
    
    	}
    }
    
     function nua_email_message_headers()
    {
    	$admin_email = get_option( 'admin_email' );
    	if ( isset($_SERVER['SERVER_NAME']) && empty($admin_email) ) {
    		$admin_email = 'support@' . sanitize_text_field(wp_unslash($_SERVER['SERVER_NAME']));
    	}
    	$from_name = get_option( 'blogname' );
    	$headers = array( "From: \"{$from_name}\" <{$admin_email}>\n" );
    	return $headers;
    }
    
    
    function nua_auto_approve_messages( $message ) 
    			{
    				$message = nua_auto_approve_message();
    				$message = nua_do_email_tags( $message, array(
    					           'context' => 'approved_message',
    					       ) );
    				return $message;
    			}
    
    function nua_bypass_new_user() {
    
    	$users_id  = array(38631, 38632, 38633, 38634, 38635, 38636);
    	return $users_id;
    }
    		
    }
    

    Please check it and let me know if you still have any issues.

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Bypass NUA upon MemberPress criteria?’ is closed to new replies.