Restrict Content Pro
rcp_user_profile_updated
Coming soon: Restrict Content Pro is becoming Kadence Memberships. You may see both names used while we update the product, documentation, and customer experience.
Note: This content is provided as a resource within our developer documentation. Because custom code requires highly specific implementation, we encourage you to work with a qualified developer if you need guidance. You can find our recommended consultants here: https://codeable.io/developers/restrict-content-pro/
Triggers when a user updates their profile through the [rcp_profile_editor] shortcode.
Parameters
$user_id(int) — ID of the user editing their profile.$userdata(array) — SubmittedWP_Userfields:ID,first_name,last_name,display_name,user_email.$old_data(WP_User) — User object from before the update.
Example:
Saving custom profile fields on this hook (same pattern as Creating Custom Registration Fields):
/**
* Store custom fields when a member updates their profile.
*
* @param int $user_id User ID.
* @param array $userdata Submitted user fields.
* @param WP_User $old_data User object before the update.
*/
function pw_rcp_save_user_fields_on_profile_save( $user_id, $userdata = array(), $old_data = null ) {
if ( ! empty( $_POST['rcp_profession'] ) ) {
update_user_meta( $user_id, 'rcp_profession', sanitize_text_field( wp_unslash( $_POST['rcp_profession'] ) ) );
}
if ( ! empty( $_POST['rcp_location'] ) ) {
update_user_meta( $user_id, 'rcp_location', sanitize_text_field( wp_unslash( $_POST['rcp_location'] ) ) );
}
}
add_action( 'rcp_user_profile_updated', 'pw_rcp_save_user_fields_on_profile_save', 10, 3 );
Filed under
Developer Docs – Actions
Was this page helpful?
Thanks for the feedback!