When a new user registers on our website, they are required to fill out their company information. This information is stored in the _usermeta table with the meta_key 'company'.
All I want to do is include this information in the notification email that Wordpress sends to the site administrator. I have had some luck manipulating pluggables.php (where the default email code is located), but I can't get any meta values to send in the email.
Here is my current code:
function wp_new_user_notification($user_id, $plaintext_pass = '') {
$user = get_userdata( $user_id );
$user_meta = get_user_meta( $user_id );
$company = $user_meta['company'][0];
// The blogname option is escaped with esc_html on the way into the database in sanitize_option
// we want to reverse this for the plain text arena of emails.
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
$message = sprintf(__('New user registration on your site %s:'), $blogname) . "
";
$message .= sprintf(__('Name: %s'), $user->display_name) . "
";
$message .= sprintf(__('E-mail: %s'), $user->user_email) . "
";
$message .= sprintf(__('Company: %s'), $company) . "
";
@wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
The code outputs:
New user registration on your site mywebsite
Name: firstname lastname
E-mail: email@example.com
Company:
I have included get_user_meta() and get_metadata() but the value is always blank.
Any help is greatly appreciated.