Changeset 3037403
- Timestamp:
- 02/18/2024 07:54:25 AM (2 years ago)
- Location:
- member-profile-fields-for-wlm-and-gf-user-registration
- Files:
-
- 2 added
- 2 edited
-
tags/1.02/languages (added)
-
trunk/languages (added)
-
trunk/member-profile-fields-for-wlm-and-gf-user-registration.php (modified) (6 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
member-profile-fields-for-wlm-and-gf-user-registration/trunk/member-profile-fields-for-wlm-and-gf-user-registration.php
r2919493 r3037403 3 3 * Plugin Name: Member Profile Fields for WishList Member and Gravity Forms User Registration Add-On 4 4 * Description: Allows setting WishList Member Fields when users are automatically created using Gravity Forms User Registration Add-On. 5 * Version: 1.0 25 * Version: 1.03 6 6 * Author: AoD Technologies LLC 7 7 * Author URI: https://aod-tech.com/ … … 12 12 * 13 13 * Member Profile Fields for WishList Member and Gravity Forms User Registration Add-On Plugin 14 * Copyright (C) 2020 - 202 3AoD Technologies LLC14 * Copyright (C) 2020 - 2024 AoD Technologies LLC 15 15 * 16 16 * This program is free software: you can redistribute it and/or modify … … 36 36 class Plugin { 37 37 private $gf_user_registration = null; 38 private $update_user_id = null; 38 39 39 40 public function __construct() { … … 55 56 56 57 add_filter( 'gform_userregistration_feed_settings_fields', array( $this, 'filter_feed_settings_fields' ) ); 58 add_filter( 'gform_user_registration_update_user_id', array( $this, 'set_filter_update_user_id_for_form_id' ), 10, 4 ); 59 add_filter( 'gform_user_registration_user_data_pre_populate', array( $this, 'filter_user_data_pre_populate' ), 10, 3 ); 57 60 58 61 add_action( 'gform_user_registered', array( $this, 'update_wlm_data' ), 5, 3 ); … … 133 136 } 134 137 138 public function set_filter_update_user_id_for_form_id( $user_id, $entry, $form, $feed ) { 139 remove_filter( 'gform_user_registration_update_user_id', array( $this, 'set_filter_update_user_id_for_form_id' ), 10, 4 ); 140 141 add_filter( 'gform_user_registration_update_user_id_' . \rgar( $form, 'id' ), array( $this, 'filter_update_user_id' ), PHP_INT_MAX, 4); 142 143 return $user_id; 144 } 145 146 public function filter_update_user_id( $user_id, $entry, $form, $feed ) { 147 remove_filter( 'gform_user_registration_update_user_id_' . \rgar( $form, 'id' ), array( $this, 'filter_update_user_id' ), PHP_INT_MAX, 4); 148 149 $this->update_user_id = $user_id; 150 151 return $user_id; 152 } 153 154 public function filter_user_data_pre_populate( $mapped_fields, $form, $feed ) { 155 if ( empty( $this->update_user_id ) ) { 156 return $mapped_fields; 157 } 158 159 $meta = $this->get_wlm_meta( $feed ); 160 161 if ( empty( $meta ) ) { 162 return $mapped_fields; 163 } 164 165 $get_member_response = \wlmapi_get_member( $this->update_user_id ); 166 if ( 167 $get_member_response['success'] === 0 || 168 empty( $get_member_response['member'] ) || 169 $get_member_response['member'][0]['ID'] === null 170 ) { 171 return $mapped_fields; 172 } 173 174 $user_info = $get_member_response['member'][0]['UserInfo']; 175 176 foreach ( $meta as $wlm_field_id => $gf_field_id ) { 177 if ( empty( $wlm_field_id ) || empty( $gf_field_id ) ) { 178 continue; 179 } 180 181 $value = null; 182 if ( in_array( $wlm_field_id, array( 'company', 'address1', 'address2', 'city', 'state', 'zip', 'country' ) ) ) { 183 $value = $user_info['wpm_useraddress'][$wlm_field_id]; 184 } else { 185 if ( strpos( $wlm_field_id, 'custom_' ) !== 0 ) { 186 $wlm_field_id = 'custom_' . $wlm_field_id; 187 } 188 189 $value = $user_info[$wlm_field_id]; 190 } 191 192 if ( empty( $value ) ) { 193 continue; 194 } 195 196 $mapped_fields[(string) $gf_field_id] = $value; 197 } 198 199 return $mapped_fields; 200 } 201 135 202 public function update_wlm_data( $user_id, $feed, $entry ) { 136 203 $wlm_data = $this->prepare_wlm_data( $user_id, $feed, $entry ); … … 188 255 189 256 new Plugin(); 190 -
member-profile-fields-for-wlm-and-gf-user-registration/trunk/readme.txt
r2919493 r3037403 4 4 Tags: gravityforms, gravity forms, wishlist member, custom fields, user fields, user profile 5 5 Requires at least: 3.5 6 Tested up to: 6. 2.26 Tested up to: 6.4.3 7 7 Requires PHP: 5.6 8 Stable tag: 1.0 28 Stable tag: 1.03 9 9 License: GPLv3 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 31 31 == Changelog == 32 32 33 = 1.03 = 34 * Pre-populate mapped fields with currently saved values in User Update feeds. 35 33 36 = 1.02 = 34 37 * Actually load the text domain.
Note: See TracChangeset
for help on using the changeset viewer.