/** * Update profile after form submission. * * @return void * @access public * @static * @since 1.0.0 */ public static function update_profile() { $form = new Charitable_Profile_Form(); if (!$form->validate_nonce()) { return; } $user = $form->get_user(); /* Verify that the user is logged in. */ if (0 == $user->ID) { return; } $fields = $form->get_merged_fields(); $submitted = apply_filters('charitable_profile_update_values', $_POST, $fields, $form); $valid = $form->check_required_fields($fields); if ($valid) { $user->update_profile($submitted, array_keys($fields)); do_action('charitable_profile_updated', $submitted, $fields, $form); } }
/** * Update profile after form submission. * * @return void * @access public * @static * @since 1.0.0 */ public static function update_profile() { $form = new Charitable_Profile_Form(); if (!$form->validate_nonce() || !$form->validate_honeypot()) { charitable_get_notices()->add_error(__('There was an error with processing your form submission. Please reload the page and try again.', 'charitable')); return; } $user = $form->get_user(); /* Verify that the user is logged in. */ if (0 == $user->ID) { return; } $fields = $form->get_merged_fields(); $submitted = apply_filters('charitable_profile_update_values', $_POST, $fields, $form); /* Remove the current_pass and user_pass_repeat fields, if set. */ unset($submitted['current_pass'], $submitted['user_pass_repeat']); $valid = $form->check_required_fields($fields); if ($valid && $form->is_changing_password()) { $valid = $form->validate_password_change(); } if ($valid) { $user->update_profile($submitted, array_keys($fields)); do_action('charitable_profile_updated', $submitted, $fields, $form); } }
/** * This adds a field to the end of the "Your Details" section in the Profile form. * * In this example, we add a Birthday field, which is a date field. * * @param array $fields * @param Charitable_Profile_Form $form */ function ed_add_user_field_to_profile_form($fields, Charitable_Profile_Form $form) { $fields['donor_birthday'] = array('label' => __('Birthday', 'your-namespace'), 'type' => 'date', 'priority' => 36, 'required' => false, 'value' => $form->get_user_value('donor_birthday')); return $fields; }
/** * Update profile after form submission. * * @return void * @access public * @static * @since 1.0.0 */ public static function update_profile() { $form = new Charitable_Profile_Form(); if (!$form->validate_nonce()) { return; } $user = $form->get_user(); /* Verify that the user is logged in. */ if (0 == $user->ID) { return; } $fields = $form->get_merged_fields(); $submitted = apply_filters('charitable_profile_update_values', $_POST, $fields, $form); /* Remove the current_pass and user_pass_repeat fields, if set. */ unset($submitted['current_pass'], $submitted['user_pass_repeat']); $valid = $form->check_required_fields($fields); if ($valid && $form->is_changing_password()) { $valid = $form->validate_password_change(); } if ($valid) { $user->update_profile($submitted, array_keys($fields)); do_action('charitable_profile_updated', $submitted, $fields, $form); } }