Admin Email - Compare User Data Before/After Editing

So, currently I can get the plugin to email me when users updated their information, however I was wondering. Is there a way to show what their information was before they saved the S2Memeber form and what it is after?

Currenty I have written

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');
$to = "test@test.co.uk";
$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_address . "<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" . print_r($olduserdata);

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

How do I edit this to show what the old user information was before it was updated?

You could probably try ws_plugin__s2member_before_handle_profile_modifications, in the same file that you found ws_plugin__s2member_during_handle_profile_modifications. s2member/src/includes/classes/profile-mods-in.inc.php

I hope that helps. :slight_smile:

Thanks! Will give this a try :slight_smile:

So, using that hook does work! I just forgot to make it work on current user rather than trying to grab a new user.

Thanks for your help :slight_smile:

1 Like

Great! :smiley:

1 Like