Skip to main content
deleted 16 characters in body
Source Link
Krzysiek Dróżdż
  • 25.5k
  • 9
  • 53
  • 74

I created a function in function.php which send an email with user information at registration. I succeed to get the ID but I can't get custom fields... I only can get these ones : - ID - user_login - user_pass - user_nicename - user_email - user_url - user_registered - display_name

I can't either get these the user_meta like first_name or last_name. I don't understand why...

Does someone know how I can do it ? In my case, my custom field is 'code_postal'.

I show you what I have done :

function mailInscriptionSecteurRhone( $user_ID ) {
        $headers = array('Content-Type: text/html; charset=UTF-8');
        $candidat = get_userdata( $user_ID );
        $codePostalCandidat = get_field('code_postal', 'user_' . $user_ID );
        wp_mail( '[email protected]', 'Test', $codePostalCandidat, $headers );
}
add_action( 'user_register', 'mailInscriptionSecteurRhone', 1 );

Thank you in advance for your help :-)

enter image description here

I created a function in function.php which send an email with user information at registration. I succeed to get the ID but I can't get custom fields... I only can get these ones : - ID - user_login - user_pass - user_nicename - user_email - user_url - user_registered - display_name

I can't either get these the user_meta like first_name or last_name. I don't understand why...

Does someone know how I can do it ? In my case, my custom field is 'code_postal'.

I show you what I have done :

function mailInscriptionSecteurRhone( $user_ID ) {
        $headers = array('Content-Type: text/html; charset=UTF-8');
        $candidat = get_userdata( $user_ID );
        $codePostalCandidat = get_field('code_postal', 'user_' . $user_ID );
        wp_mail( '[email protected]', 'Test', $codePostalCandidat, $headers );
}
add_action( 'user_register', 'mailInscriptionSecteurRhone', 1 );

Thank you in advance for your help :-)

enter image description here

I created a function in function.php which send an email with user information at registration. I succeed to get the ID but I can't get custom fields... I only can get these ones : - ID - user_login - user_pass - user_nicename - user_email - user_url - user_registered - display_name

I can't either get these the user_meta like first_name or last_name. I don't understand why...

Does someone know how I can do it ? In my case, my custom field is 'code_postal'.

I show you what I have done :

function mailInscriptionSecteurRhone( $user_ID ) {
    $headers = array('Content-Type: text/html; charset=UTF-8');
    $candidat = get_userdata( $user_ID );
    $codePostalCandidat = get_field('code_postal', 'user_' . $user_ID );
    wp_mail( '[email protected]', 'Test', $codePostalCandidat, $headers );
}
add_action( 'user_register', 'mailInscriptionSecteurRhone', 1 );

Thank you in advance for your help :-)

enter image description here

Source Link
Arthur
  • 1
  • 1
  • 1

Get user custom field value on function.php

I created a function in function.php which send an email with user information at registration. I succeed to get the ID but I can't get custom fields... I only can get these ones : - ID - user_login - user_pass - user_nicename - user_email - user_url - user_registered - display_name

I can't either get these the user_meta like first_name or last_name. I don't understand why...

Does someone know how I can do it ? In my case, my custom field is 'code_postal'.

I show you what I have done :

function mailInscriptionSecteurRhone( $user_ID ) {
        $headers = array('Content-Type: text/html; charset=UTF-8');
        $candidat = get_userdata( $user_ID );
        $codePostalCandidat = get_field('code_postal', 'user_' . $user_ID );
        wp_mail( '[email protected]', 'Test', $codePostalCandidat, $headers );
}
add_action( 'user_register', 'mailInscriptionSecteurRhone', 1 );

Thank you in advance for your help :-)

enter image description here