Hello @stewarttodd,
Please try this code on your site and let us know if you still have any issues, we hope this snippet of code will fulfill your need.
Here is the code:
add_filter('new_user_approve_request_approval_message', 'nua_update_status_by_email', 10, 3);
function nua_update_status_by_email($message, $user_login, $user_email) {
$user = get_user_by('email', $user_email);
$user_id = $user->ID;
$nonce = wp_create_nonce('nua_update_user');
$approve_link = add_query_arg(array('user-action'=>'approved', 'user-id' => $user_id, 'nonce' => $nonce ), site_url());
$approve_link = sprintf(__('Approve : %s','new-user-approve' ), $approve_link );
$deny_link = add_query_arg( array('user-action'=>'denied', 'user-id' => $user_id, 'nonce' => $nonce ) , site_url());
$deny_link = sprintf(__('Deny : %s','new-user-approve' ), $deny_link );
$message.='</br>';
$message.=$approve_link;
$message.='</br>';
$message.=$deny_link;
return $message;
}
add_action('init', 'approve_deny_user');
function approve_deny_user() {
if( isset( $_GET['user-action']) && isset($_GET['user-id'])) {
$status = $_GET['user-action'];
$user_id = $_GET['user-id'];
update_user_meta($user_id, 'pw_user_status', $status);
}
}
If you have any questions, feel free to reach out. We’re here to assist you.
Thank you