$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>hooks - How to get user profile information before update?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

hooks - How to get user profile information before update?

matteradmin10PV0评论

Currently I can send an email to admin when users update their information using the following (hooking into the S2Memeber plugin):

// Email to tell us what user profile for CMM has been modified
add_action ('ws_plugin__s2member_during_handle_profile_modifications', 'email_profile_changes');
function email_profile_changes($vars = array()) {
    $user = new WP_User($vars['user_id']);

add_filter('wp_mail_content_type', 'wpdocs_set_html_mail_content_type');
$old_meta = get_user_meta($user->ID);
$to = "[email protected]";
$subject = "Profile Update - $user->user_login";
$body = "This user has updated their CMM profile information, here is their new profile data for audit purposes: <br/>" .
        "<hr>" .
        "First Name: " . $user->first_name . "<br/>" .
        "<hr>" .
        "Last Name: " . $user->last_name . "<br/>" .
        "<hr>" .
        "Email Address: " . $user->email . "<br/>" .
        "<hr>" .
        "Address: " . $user->wp_s2member_custom_fields['company_address'] . "<br/>" .
        "<hr>" .
        "Telephone Number: " . $user->wp_s2member_custom_fields['telephone_number'] . "<br/>" .
        "<hr>" .
        "Old User Data";

wp_mail ($to, $subject, $body);
    remove_filter( 'wp_mail_content_type', 'wpdocs_set_html_mail_content_type' );
}

For audit purposes i've been asked if it's possible to show their user information before update as well as their changed data?

How would I go about modifying this to do that? I'm assuming wordpress databases just overwrite this data when it's saved and it's therefore not possible?

Any help would be appreciated to determine if it's possible or not?

Currently I can send an email to admin when users update their information using the following (hooking into the S2Memeber plugin):

// Email to tell us what user profile for CMM has been modified
add_action ('ws_plugin__s2member_during_handle_profile_modifications', 'email_profile_changes');
function email_profile_changes($vars = array()) {
    $user = new WP_User($vars['user_id']);

add_filter('wp_mail_content_type', 'wpdocs_set_html_mail_content_type');
$old_meta = get_user_meta($user->ID);
$to = "[email protected]";
$subject = "Profile Update - $user->user_login";
$body = "This user has updated their CMM profile information, here is their new profile data for audit purposes: <br/>" .
        "<hr>" .
        "First Name: " . $user->first_name . "<br/>" .
        "<hr>" .
        "Last Name: " . $user->last_name . "<br/>" .
        "<hr>" .
        "Email Address: " . $user->email . "<br/>" .
        "<hr>" .
        "Address: " . $user->wp_s2member_custom_fields['company_address'] . "<br/>" .
        "<hr>" .
        "Telephone Number: " . $user->wp_s2member_custom_fields['telephone_number'] . "<br/>" .
        "<hr>" .
        "Old User Data";

wp_mail ($to, $subject, $body);
    remove_filter( 'wp_mail_content_type', 'wpdocs_set_html_mail_content_type' );
}

For audit purposes i've been asked if it's possible to show their user information before update as well as their changed data?

How would I go about modifying this to do that? I'm assuming wordpress databases just overwrite this data when it's saved and it's therefore not possible?

Any help would be appreciated to determine if it's possible or not?

Share Improve this question edited Jan 11, 2019 at 15:13 fuxia 107k39 gold badges255 silver badges461 bronze badges asked Jan 11, 2019 at 14:00 user158811user158811 1 1
  • It's hard to tell because of the plugin you're using. WP Core has a hook called profile_update which would allow you to pull the old data from the database and the new data from the POST request, but your plugin is using a different hook. You may need to contact the plugin author who is more familiar with how the plugin modifies behavior and see whether you can use one of the plugin's hooks. – WebElaine Commented Jan 11, 2019 at 14:39
Add a comment  | 

1 Answer 1

Reset to default 0

So, I managed to do this by using as a hook ws_plugin__s2member_before_handle_profile_modifications

Post a comment

comment list (0)

  1. No comments so far