X

Enviar una notificación por correo electrónico cuando se actualice el perfil

Snippets by IsItWP

¿Está buscando una manera de enviar una notificación por correo electrónico a los usuarios de WordPress cuando se actualiza su perfil? Si bien es probable que haya un plugin para esto, hemos creado un fragmento de código rápido que puede utilizar para enviar notificaciones por correo electrónico cuando se actualiza el perfil en WordPress.

Instrucciones:

Todo lo que tienes que hacer es añadir este código al archivo functions.php de tu tema o en un plugin específico del sitio:

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);

Nota: Si es la primera vez que añade fragmentos de código en WordPress, consulte nuestra guía sobre cómo copiar / pegar correctamente fragmentos de código en WordPress, para no romper accidentalmente su sitio.

Si te ha gustado este fragmento de código, por favor considere revisar nuestros otros artículos en el sitio como: 10 mejores plugins de testimonios de WordPress para agregar prueba social y 18 alternativas de Jetpack para obtener las características sin bloat.

Comentarios   Deja una respuesta

  1. 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)

  2. Hello,

    Is there a way to have the email highlight what part of their profile was updated?

    Thank you!

    1. 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.

  3. 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!

    1. You could use this snippet and change the $to variable to your email address.

  4. 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 !

    1. You may want to check that the “profile_update” hook is not being run twice.

  5. Can we send email when specific field is updated ?

  6. 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

  7. its workin perfectly. but mail is showing to spam folder

    🙁

    1. Not much can be down about that, I would think it has to do with spam settings.

    2. Chrys Mahoungou agosto 27, 2019 en 8:41 am

      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

Añadir un comentario

Nos alegra que haya decidido dejar un comentario. Tenga en cuenta que todos los comentarios se moderan de acuerdo con nuestra política de privacidad , y que todos los enlaces son nofollow. NO utilice palabras clave en el campo del nombre. Tengamos una conversación personal y significativa.

WordPress Launch Checklist

La lista definitiva para lanzar WordPress

Hemos recopilado todos los elementos esenciales de la lista de comprobación para el lanzamiento de su próximo sitio web de WordPress en un práctico ebook.
Sí, envíeme el ¡gratuito!