Created
March 8, 2023 15:14
-
-
Save dparker1005/628b70478eb279a5c0af15debf810327 to your computer and use it in GitHub Desktop.
Do not update user's first and last name while on the PMPro Checkout page. Useful if you do not want the user's billing name to be the name on the account.
This file contains 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 | |
// Copy from below here. | |
/** | |
* Do not update user's first and last name while on the PMPro Checkout page. | |
* Useful if you do not want the user's billing name to be the name on the account. | |
*/ | |
function my_pmpro_prevent_name_save_at_checkout( $check, $object_id, $meta_key ) { | |
if ( $meta_key === 'first_name' || $meta_key === 'last_name' ) { | |
if ( function_exists( 'pmpro_is_checkout' ) && pmpro_is_checkout() ) { | |
return false; // Do not update user meta. | |
} | |
} | |
return $check; | |
} | |
add_filter( 'update_user_metadata', 'my_pmpro_prevent_name_save_at_checkout', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment