Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    That could be done, but it wouldn’t be a simple process.

    Using a combination of the wpmem_pre_update_data and wpmem_post_update_data action hooks, you could compare the user’s currently recorded information with what they are updating, and if an update is made, generate an email notification.

    Thread Starter yanks789

    (@yanks789)

    I am pretty familiar with WordPress and coding but am not familiar with the action hooks and making it work with the existing plugin. Can you help me with the action hooks? Or give me a little direction on how to go about this?

    Plugin Author Chad Butler

    (@cbutlerjr)

    Sure – action hooks are places you can hook a function to to do certain things, in this case look at if a user is changing information, and then if so, sending an email.

    Take a look at the WP Codex for information on add_action.

    For example, you are going to hook a function to the wpmem_pre_update_data hook it would be something like:

    add_action( 'wpmem_pre_update_data', 'my_function' );

    Then my_function could look at the existing data that a user has in the db, to determine if what they are submitting is in any way different.

    Then you would write a second function and hook it to wpmem_post_update_data (which comes after the action data has been updated).

    add_action( 'wpmem_post_update_data', 'my_other_function' );

    In my_other_function, you would send and email (probably using wp_mail) if my_function resulted in a situation where data was in fact being updated.

    Note: it will be important to reference the hook documentation referenced above for these hooks – they are similar – so that you know what parameters are passed to the action. In this case, $fields is passed, which is an array containing all of the posted data.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Email notification when a user edits their info’ is closed to new replies.