Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- @ Send email to admin if user updated his profile - Expand version
- @
- **/
- function wpuf_user_profile_update_notification( $user_id ) {
- if (!current_user_can( 'administrator' )){// avoid sending emails when admin is updating user profiles
- $user_info = get_userdata( $user_id );
- $to = get_option( 'admin_email' ) .", ".$user_info->user_email;
- $subject = $user_info->display_name . " Profile Updated";
- //Get user custom Meta
- $phone = get_user_meta( $user_id, 'phone', true );
- $address_field = get_user_meta( $user_id, 'address_field', true );
- // Message body
- $message .= "The user (". $user_info->display_name. ") has updated his profile with:". "\n\n";
- // Show user meta which you want to show on the email message
- $message .= 'Phone: ' . $phone . "\n";
- // $message .= 'Address: ' . $address_field['street_address'] .", ". $address_field['street_address2'] .", ". $address_field['city_name'] . ", ". $address_field['zip'] . ", ". $address_field['state'] . ", ". $address_field['country_select'] . "\n";
- $message .= 'Address:'. "\n";
- $message .= 'Street 1- ' . $address_field['street_address'] . "\n";
- $message .= 'Street 2- ' . $address_field['street_address2'] . "\n";
- $message .= 'City- ' . $address_field['city_name'] . "\n";
- $message .= 'Post/Zip- ' . $address_field['zip'] . "\n\n";
- $message .= 'Site Address: ' . get_bloginfo('wpurl') . "\n";
- wp_mail( $to, $subject, $message);
- }
- }
- add_action( 'wpuf_update_profile', 'wpuf_user_profile_update_notification', 10, 3 ); //This action fire while WPUF Profile form update
- add_action( 'profile_update', 'wpuf_user_profile_update_notification', 10, 2); //This action fire while default WordPress profile update
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement