Membership 2 Pro automated emails for admins

Email responses allow the option 'Send copy to administrator'. But I do not apply the administrator role to my clients, instead I just make a copy of the role so I can prevent them from making crazy mistakes. But m2 does not recognize their custom role as another version of administrator, and Id like them to know when a user signs up for their site. Any thoughts? How could I check for my new custom "Admin" role?

  • Ivan

    Hi Nathan !

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

    <?php
    function wpmu_m2_add_custom_admin_role_to_email_responses( $admins ) {
    	$args 	= array(
    		'role' 		=> 'author',
    		'fields' 	=> array( 'ID', 'user_email' ),
    	);
    
    	$wp_user_search = new WP_User_Query( $args );
    	$users 			= $wp_user_search->get_results();
    
    	if ( ! empty ($users ) ) {
    		foreach ( $users as $user ) {
    			$admins[ $user->user_email ] = $user->user_email;
    		}
    	}
    
    	return $admins;
    }
    
    add_filter( 'ms_model_member_get_admin_user_emails', 'wpmu_m2_add_custom_admin_role_to_email_responses' );

    Note: You should edit role value to your custom role instead of author value.

    Best,
    Ivan.