description-property.php
3 years ago
display-name-property.php
3 years ago
first-name-property.php
3 years ago
last-name-property.php
3 years ago
nick-name-property.php
3 years ago
update-action.php
3 years ago
user-confirm-password-property.php
3 years ago
user-email-property.php
3 years ago
user-id-property.php
3 years ago
user-meta-property.php
3 years ago
user-modifier.php
3 years ago
user-nicename-property.php
3 years ago
user-password-property.php
3 years ago
user-role-property.php
3 years ago
user-url-property.php
3 years ago
user-meta-property.php
44 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | namespace Jet_Form_Builder\Actions\Methods\Update_User; |
| 5 | |
| 6 | |
| 7 | use Jet_Form_Builder\Actions\Methods\Abstract_Modifier; |
| 8 | use Jet_Form_Builder\Actions\Methods\Base_Object_Property; |
| 9 | use Jet_Form_Builder\Actions\Methods\Object_Dynamic_Property; |
| 10 | use Jet_Form_Builder\Classes\Tools; |
| 11 | |
| 12 | class User_Meta_Property extends Base_Object_Property implements Object_Dynamic_Property { |
| 13 | |
| 14 | protected $meta = array(); |
| 15 | |
| 16 | public function get_id(): string { |
| 17 | return 'user_meta'; |
| 18 | } |
| 19 | |
| 20 | public function get_label(): string { |
| 21 | return __( 'User Meta', 'jet-form-builder' ); |
| 22 | } |
| 23 | |
| 24 | public function is_supported( string $key, $value ): bool { |
| 25 | return true; |
| 26 | } |
| 27 | |
| 28 | public function do_before( string $key, $value, Abstract_Modifier $modifier ) { |
| 29 | if ( ! Tools::is_repeater_val( $value ) ) { |
| 30 | $this->meta[ $key ] = $value; |
| 31 | |
| 32 | return; |
| 33 | } |
| 34 | |
| 35 | $this->meta[ $key ] = Tools::prepare_repeater_value( $value, $modifier->fields_map ); |
| 36 | } |
| 37 | |
| 38 | public function do_after( Abstract_Modifier $modifier ) { |
| 39 | foreach ( $this->meta as $key => $value ) { |
| 40 | update_user_meta( $modifier->source_arr['ID'], $key, $value ); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | } |