コード例 #1
0
 /**
  * Update the WordPress user profile based on the GF User Registration create feed
  *
  * @since 1.11
  *
  * @param array $form Gravity Forms form array
  * @param string $entry_id Gravity Forms entry ID
  * @return void
  */
 public function update_user($form = array(), $entry_id = 0)
 {
     if (!class_exists('GFAPI') || !class_exists('GFUser') || empty($entry_id)) {
         return;
     }
     // support for GF User Registration 3.x
     $gf_user_3 = class_exists('GF_User_Registration') ? true : false;
     if ($gf_user_3) {
         $gf_user_registration = GF_User_Registration::get_instance();
     }
     $entry = GFAPI::get_entry($entry_id);
     /**
      * @filter `gravityview/edit_entry/user_registration/entry` Modify entry details before updating the user via User Registration add-on
      * @since 1.11
      * @param array $entry Gravity Forms entry
      * @param array $form Gravity Forms form
      */
     $entry = apply_filters('gravityview/edit_entry/user_registration/entry', $entry, $form);
     /**
      * @since 1.14
      */
     if ($gf_user_3) {
         $config = $gf_user_registration->get_single_submission_feed($entry, $form);
     } else {
         $config = GFUser::get_active_config($form, $entry);
     }
     /**
      * @filter `gravityview/edit_entry/user_registration/preserve_role` Keep the current user role or override with the role defined in the Create feed
      * @since 1.15
      * @param[in,out] boolean $preserve_role Preserve current user role Default: true
      * @param[in] array $config Gravity Forms User Registration feed configuration for the form
      * @param[in] array $form Gravity Forms form array
      * @param[in] array $entry Gravity Forms entry being edited
      */
     $preserve_role = apply_filters('gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry);
     if ($preserve_role) {
         $config['meta']['role'] = 'gfur_preserve_role';
     }
     /**
      * Make sure the current display name is not changed with the update user method.
      * @since 1.15
      */
     $config['meta']['displayname'] = $this->match_current_display_name($entry['created_by']);
     /**
      * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
      * @since 1.14
      * @param[in,out] array $config Gravity Forms User Registration feed configuration for the form
      * @param[in] array $form Gravity Forms form array
      * @param[in] array $entry Gravity Forms entry being edited
      */
     $config = apply_filters('gravityview/edit_entry/user_registration/config', $config, $form, $entry);
     $feed_pos = $gf_user_3 ? 'meta/feedType' : 'meta/feed_type';
     $is_create_feed = $config && rgars($config, $feed_pos) === 'create';
     // Only update if it's a create feed
     if (!$is_create_feed) {
         return;
     }
     // The priority is set to 3 so that default priority (10) will still override it
     add_filter('send_password_change_email', '__return_false', 3);
     add_filter('send_email_change_email', '__return_false', 3);
     // Trigger the User Registration update user method
     if ($gf_user_3) {
         $gf_user_registration->update_user($entry, $form, $config);
     } else {
         GFUser::update_user($entry, $form, $config);
     }
     remove_filter('send_password_change_email', '__return_false', 3);
     remove_filter('send_email_change_email', '__return_false', 3);
 }
コード例 #2
0
 /**
  * Process validation for a edit entry submission
  *
  * Sets the `is_valid` object var
  *
  * @return void
  */
 function validate()
 {
     /**
      * If using GF User Registration Add-on, remove the validation step, otherwise generates error when updating the entry
      * GF User Registration Add-on version > 3.x has a different class name
      * @since 1.16.2
      */
     if (class_exists('GF_User_Registration')) {
         remove_filter('gform_validation', array(GF_User_Registration::get_instance(), 'validate'));
     } else {
         if (class_exists('GFUser')) {
             remove_filter('gform_validation', array('GFUser', 'user_registration_validation'));
         }
     }
     /**
      * For some crazy reason, Gravity Forms doesn't validate Edit Entry form submissions.
      * You can enter whatever you want!
      * We try validating, and customize the results using `self::custom_validation()`
      */
     add_filter('gform_validation_' . $this->form_id, array($this, 'custom_validation'), 10, 4);
     // Needed by the validate funtion
     $failed_validation_page = NULL;
     $field_values = RGForms::post('gform_field_values');
     // Prevent entry limit from running when editing an entry, also
     // prevent form scheduling from preventing editing
     unset($this->form['limitEntries'], $this->form['scheduleForm']);
     // Hide fields depending on Edit Entry settings
     $this->form['fields'] = $this->get_configured_edit_fields($this->form, $this->view_id);
     $this->is_valid = GFFormDisplay::validate($this->form, $field_values, 1, $failed_validation_page);
     remove_filter('gform_validation_' . $this->form_id, array($this, 'custom_validation'), 10);
 }