Is there a way or a snippet that can be created to automatically send an automatic email to users who we manually approve stating there account has been approved.
To go a little in-depth about this - User's are able to sign up to our website and the information is sent to the website, we have a custom plugin that display certain information the user entered, the information is displayed through using Advanced Custom Fields. In the customised plugin section we have "login allowed" checkbox, i want it so when i check this and click update user, the email is sent.
The email would be automatically retrieved from the wordpress's default "Basic information" section if possible. Any guidance / clarification & feedback is majorly appreciated.
EDIT:
add_action(‘acf/save_post’, ‘my_save_post’);
function my_save_post( $post_id ) {
// create some logic here to check if you are editing a user
global $pagenow;
if ($pagenow == ‘user-edit.php’) {
//get the value of the field
$value = get_field(‘login_allowed’,$post_id);
// check if the checkbox is filled
if ( ! $value ='unchecked' ) {
return false;
}
$value == 'checked'{
// Company information
$email = “removed”;
$name = “removed”;
//get user's email
$user = get_user_by('email', $useremail);
if ($user) {
$details['email'] = $user->user_email;
// email data
$to = $useremail;
$subject = 'The subject';
$body = 'The email body content';
$headers = ‘From:‘ . $name . ‘ <‘ . $email . ‘>’ . “\r\n”;
// send email
wp_mail($to, $subject, $body, $headers );
}
}
}
}