/**
  * Update registration after form submission. 
  *
  * @return  void
  * @access  public
  * @static
  * @since   1.0.0
  */
 public static function save_registration()
 {
     $form = new Charitable_Registration_Form();
     if (!$form->validate_nonce()) {
         return;
     }
     $fields = $form->get_fields();
     $valid = $form->check_required_fields($fields);
     if (!$valid) {
         return;
     }
     $submitted = apply_filters('charitable_registration_values', $_POST, $fields, $form);
     $user = new Charitable_User();
     $user->update_profile($submitted, array_keys($fields));
     if (isset($submitted['user_pass'])) {
         $creds = array();
         $creds['user_login'] = isset($submitted['user_login']) ? $submitted['user_login'] : $user->user_login;
         $creds['user_password'] = $submitted['user_pass'];
         $creds['remember'] = true;
         wp_signon($creds, false);
     }
     wp_safe_redirect(charitable_get_login_redirect_url());
     exit;
 }
 /**
  * Update registration after form submission.
  *
  * @return  void
  * @access  public
  * @static
  * @since   1.0.0
  */
 public static function save_registration()
 {
     $form = new Charitable_Registration_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;
     }
     $fields = $form->get_fields();
     $valid = $form->check_required_fields($fields);
     if (!$valid) {
         return;
     }
     $submitted = apply_filters('charitable_registration_values', $_POST, $fields, $form);
     if (!isset($submitted['user_email']) || !is_email($submitted['user_email'])) {
         charitable_get_notices()->add_error(sprintf(__('%s is not a valid email address.', 'charitable'), $submitted['user_email']));
         return false;
     }
     $user = new Charitable_User();
     $user_id = $user->update_profile($submitted, array_keys($fields));
     /**
      * If the user was successfully created, redirect to the login redirect URL.
      * If there was a problem, this simply falls through and keeps the user on the
      * registration page.
      */
     if ($user_id) {
         wp_safe_redirect(charitable_get_login_redirect_url());
         exit;
     }
 }
 /**
  * Update registration after form submission.
  *
  * @return  void
  * @access  public
  * @static
  * @since   1.0.0
  */
 public static function save_registration()
 {
     $form = new Charitable_Registration_Form();
     if (!$form->validate_nonce()) {
         return;
     }
     $fields = $form->get_fields();
     $valid = $form->check_required_fields($fields);
     if (!$valid) {
         return;
     }
     $submitted = apply_filters('charitable_registration_values', $_POST, $fields, $form);
     $user = new Charitable_User();
     $user_id = $user->update_profile($submitted, array_keys($fields));
     /**
      * If the user was successfully created, redirect to the login redirect URL.
      * If there was a problem, this simply falls through and keeps the user on the
      * registration page.
      */
     if ($user_id) {
         wp_safe_redirect(charitable_get_login_redirect_url());
         exit;
     }
 }