Vous cherchez un moyen d’envoyer une notification par email aux utilisateurs de WordPress lorsque leur profil est mis à jour ? Bien qu’il existe probablement un plugin pour cela, nous avons créé un extrait de code rapide que vous pouvez utiliser pour envoyer une notification par email lorsque le profil est mis à jour dans WordPress.
Instructions:
Tout ce que vous avez à faire est d’ajouter ce code dans le fichier functions.php de votre thème ou dans un plugin spécifique à votre site:
function user_profile_update( $user_id ) { $site_url = get_bloginfo('wpurl'); $user_info = get_userdata( $user_id ); $to = $user_info->user_email; $subject = "Profile Updated: ".$site_url.""; $message = "Hello " .$user_info->display_name . "nYour profile has been updated!nnThank you for visitingn ".$site_url.""; wp_mail( $to, $subject, $message); } add_action( 'profile_update', 'user_profile_update', 10, 2);
Note : Si c’est la première fois que vous ajoutez des extraits de code dans WordPress, veuillez vous référer à notre guide sur comment copier/coller correctement des extraits de code dans WordPress, afin de ne pas casser accidentellement votre site.
Si vous avez aimé cet extrait de code, n’hésitez pas à consulter nos autres articles sur le site comme : 10 meilleurs plugins WordPress de témoignages pour ajouter de la preuve sociale et 18 alternatives à Jetpack pour obtenir les fonctionnalités sans le gonflement.
Can you set it up so it ONLY emails when and admin changes the user profile? In fluent SMTP it is showing that its sending double emails. One when they create the account (I am assuming) and one when I change something on their profile (i am just allocating items to their account by assigning them a specific brand)
Hello,
Is there a way to have the email highlight what part of their profile was updated?
Thank you!
Sadly we don’t currently have a snippet for this.
You may want to check out the profile_update hook: https://developer.wordpress.org/reference/hooks/profile_update/
You may be able to add arguments for the $old_user_data and $userdata objects to the user_profile_update function and compare the two objects.
Hi there!
I operate a directory based website where members register using ultimate member and then I create listings on a map with a seperate plugin.
Problem is is when a user updates their profile, I have no way of knowing and I’m not able to manually update the map listing when their profile has been changed.
Is there a way that I, as administrator, can receive an email every time EVERY user makes a change to their profile?
Thank you!
You could use this snippet and change the
$to
variable to your email address.BRAVO MERCI ! Mais ça m’envoie deux fois le mail…
function user_profile_update( $user_id ) {
$site_url = get_bloginfo(‘wpurl’);
$user_info = get_userdata( $user_id );
$to =”[email protected]”;
$subject = “Mise a jour profil: ” .$user_info->display_name . “”;
$message = “Le profil: ” .$user_info->display_name . ” a ete mis a jour \n\nRentre tout ca dans ACCESS au lieu de me regarder betement\n “;
wp_mail( $to, $subject, $message);
}
add_action( ‘profile_update’, ‘user_profile_update’, 10, 2);
J’ai pas trouvé de solution … Encore Merci !
You may want to check that the “profile_update” hook is not being run twice.
Can we send email when specific field is updated ?
Hello please i am new to wordpress,i want to set up multiple users which i have been able to do but also i want users to be notified via mail when new posts are added or updates are added.I read up your wordpress snippet on adding the codes u have above to function.php i cant find this function.php anywhere on my C drive.Please help out thanks
its workin perfectly. but mail is showing to spam folder
🙁
Not much can be down about that, I would think it has to do with spam settings.
I think if is showing as spam you can just mark as not a spam.correct me of i didn’t get properly your question