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
update-action.php
34 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_Modifier_Action; |
| 9 | use Jet_Form_Builder\Exceptions\Action_Exception; |
| 10 | |
| 11 | class Update_Action extends Base_Modifier_Action { |
| 12 | |
| 13 | public function get_id(): string { |
| 14 | return 'update'; |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * @throws Action_Exception |
| 19 | */ |
| 20 | public function do_action() { |
| 21 | $response = wp_update_user( $this->modifier->source_arr ); |
| 22 | |
| 23 | if ( is_wp_error( $response ) ) { |
| 24 | throw new Action_Exception( |
| 25 | $response->get_error_message(), |
| 26 | $response->get_error_data() |
| 27 | ); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | public static function is_supported( Abstract_Modifier $modifier ): bool { |
| 32 | return 'update_user' === jet_fb_action_handler()->get_current_action()->get_id(); |
| 33 | } |
| 34 | } |