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