-
Php WP how to send a mail to the admin from a logged user
almost 9 years ago
-
almost 9 years ago
To retrieve data of logged-in user & send all the data to admin with user message.
a. Get user data of logged-in user.
global $current_user; get_currentuserinfo(); $message = 'Username: ' . $current_user->user_login . "\n"; $message .= 'User email: ' . $current_user->user_email . "\n"; $message .= 'User level: ' . $current_user->user_level . "\n"; $message .= 'User first name: ' . $current_user->user_firstname . "\n"; $message .= 'User last name: ' . $current_user->user_lastname . "\n"; $message .= 'User display name: ' . $current_user->display_name . "\n"; $message .= 'User ID: ' . $current_user->ID . "\n"; $message .= $_POST['name_of_text_area'];
b. Retrieve the e-mail of the administrator.
$admin_email = get_option( 'admin_email' );
c. Send email to admin
wp_mail( $admin_email, 'Subject', $message );
Please let me know if you need anything else.
-
1 Answer(s)