Title: Executing wpmail() when user info changes
Last modified: August 21, 2016

---

# Executing wpmail() when user info changes

 *  Resolved [Senff – a11n](https://wordpress.org/support/users/senff/)
 * (@senff)
 * [12 years, 5 months ago](https://wordpress.org/support/topic/executing-wpmail-when-user-info-changes/)
 * So, working with a site that’s built by someone else. Plugins and hacks are not
   guaranteed to be done exactly right, but this is what I have right now:
 * Every user in the system (standard WP users, level subscriber) has some extra
   information fields, created by some custom plugin. One is a YES/NO checkbox that
   states whether or not the user will be listed on the site. Works fine.
 * However, I want to add functionality so that a **wpmail()** function is fired
   when that setting for any user changes from NO to YES. Hence:
 * 1. open user details at [http://www.mysite.com/wp-admin/users.php](http://www.mysite.com/wp-admin/users.php)
   
   2. click on user to view details 3. change checkbox from unchecked to checked
   4. hit UPDATE PROFILE button
 * And so right after that, the **wpmail()** needs to be executed.
 * I will hardcode the recipient and message and such, but I need to know how/where
   I put the actual execution. Dirty solutions are accepted, the site is a mess 
   already anyway. 😉 But since it probably involves creating a plugin solution,
   I’ve put it in this section (feel free to move if it’s misplaced).
 * Thanks for your help!

Viewing 1 replies (of 1 total)

 *  Thread Starter [Senff – a11n](https://wordpress.org/support/users/senff/)
 * (@senff)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/executing-wpmail-when-user-info-changes/#post-4432429)
 *     ```
       <?php
       	add_action('edit_user_profile_update', 'update_extra_profile_fields');
       	function update_extra_profile_fields($user_id) {
       			$showuser = $_POST['show'];
       			if ($showuser == 'on') {
       				$useremail = get_user_meta($user_id, 'nickname', true);
       				$emailmessage = "Some message goes here...";
       				wp_mail($useremail, 'Here goes the subject', $emailmessage, 'From: WP Notification <user@domain.com>');
       			}
       	    }
       ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Executing wpmail() when user info changes’ is closed to new replies.

## Tags

 * [wpmail](https://wordpress.org/support/topic-tag/wpmail/)

 * 1 reply
 * 1 participant
 * Last reply from: [Senff – a11n](https://wordpress.org/support/users/senff/)
 * Last activity: [12 years, 3 months ago](https://wordpress.org/support/topic/executing-wpmail-when-user-info-changes/#post-4432429)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
