1

I am running a WordPress site for real estate and I cannot seem to figure out how to receive an email when a new user registers or downloads information from my site. If anyone could help me figure out how to turn these notifications on or what plugin I should use to receive these notifications that would be greatly appreciated.

2 Answers 2

0

This is an easy way to get to get emails upon user registration - just needs to be added to your function.php file.

function registration_email_alert($user_id) {
    $message = strip_tags($_POST['user_login']). ' - ' . strip_tags($_POST['user_email']) . ' Has Registered To Your Website';
    wp_mail( '[email protected]', 'New User Has Registered', $message );
}
add_action('user_register', 'registration_email_alert');

I'm sure there's also a way to get notified upon downloads but that might take extra time to figure out.

0

To send a notification email when a user registers on your WordPress website, you can use the wp_mail() function. Here's an example of a custom function you can add to your theme's functions.php file or a custom plugin:

// Hook into the user registration process
add_action('user_register', 'send_notification_on_registration', 10, 1);

function send_notification_on_registration($user_id) {
// Get user data
$user_info = get_userdata($user_id);

// Set the recipient email address
$to = '[email protected]';

// Set the subject for the email
$subject = 'New User Registration';

// Set the message for the email
$message = 'A new user has registered on your website.' . "\n\n";
$message .= 'Username: ' . $user_info->user_login . "\n";
$message .= 'Email: ' . $user_info->user_email . "\n";

// Additional headers
$headers = array('Content-Type: text/html; charset=UTF-8');

// Send the email
wp_mail($to, $subject, $message, $headers);
}

Replace '[email protected]' with the actual email address where you want to receive the notification. This function uses the user_register action hook to trigger the email when a new user registers on your site.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.