Created
June 23, 2021 19:12
-
-
Save mehul0810/cc416a47158045dc34431ba42da46ec6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This code snippet will help you update the email address on donor as well as WP user profiles when donor updates the email address | |
* using legacy donor profile `[give_profile_editor]`. | |
* | |
* @param int $user_id WP User ID. | |
* @param array $userdata WP User data. | |
* | |
* @return void | |
*/ | |
function custom_prefix_update_donor_email( $user_id, $userdata ) { | |
// Get GiveWP donor data. | |
$donor = new Give_Donor( $user_id, true ); | |
// Update email to donor profile only if the email in donor profile doesn't match with the submitted one. | |
if ( $userdata['user_email'] !== $donor->email ) { | |
$donor->update( [ | |
'email' => $userdata['user_email'], | |
] ); | |
} | |
} | |
add_action( 'give_user_profile_updated', 'custom_prefix_update_donor_email', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment