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