• Hi!!
    I′ve tried to send a mail with info of my new user, when user is registered; all works ok, but the registration form is customized, so there are some information in wp-usermeta table. I′ve tried this but it doesn′t work, the word appear empty in the mail.
    Do you know what the problem is? Thank you!!

    function so174837_registration_email_alert( $user_id ) {
    $user = get_userdata( $user_id );
    $email = $user->user_email;
    $userlogin =$user->user_login;

    //MY ACCESS USERMETA ATTEMPT
    $usermeta = get_user_meta($user_id);
    $namekid = $usermeta[‘name_kid’];

    $message = ‘NUEVO USUARIO:’.$email . ‘ has registered to your website. The name is ‘ .$userlogin. ‘ and the kid name is ‘ .$namekid;
    wp_mail( ‘[valid email address redacted]’, ‘New User registration’, $message );
    }
    add_action(‘user_register’, ‘so174837_registration_email_alert’);

    • This topic was modified 7 years, 8 months ago by bcworkz. Reason: remove real email from wp_mail() call
Viewing 2 replies - 1 through 2 (of 2 total)
  • I think you’re getting back an array of arrays, so you would need to further drill down inside the variable. From the documentation:

    Note: …you need to dereference the array that is returned for each key, like so:

    $last_name = $all_meta_for_user['last_name'][0];

    Have you tried this? E.g.

    $namekid = $usermeta[‘name_kid’][0];

    Another option is targeting what you need exactly:

    $namekid = get_user_meta( $user_id, 'name_kid' , true );

    • This reply was modified 7 years, 8 months ago by montrealist.
    • This reply was modified 7 years, 8 months ago by montrealist.
    Thread Starter isabelgalvez

    (@isabelgalvez)

    I′ve tried, and doesn′t work =(, but makes sense!
    Thanks in any case!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘show wp-usermeta value in email’ is closed to new replies.