Created
June 17, 2023 06:31
-
-
Save moxet/5ac641b90fec36df10eeb0403c97c602 to your computer and use it in GitHub Desktop.
Activate User with Hook using JFB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'jet-form-builder/custom-action/activate_user', function( $request, $action_handler ) { | |
| //Getting code value from JFB | |
| $code = $request['code']; | |
| //Check all users who has the Unique code from URL | |
| $users = get_users(array('meta_key' => 'code', 'meta_value' => $code)); | |
| if(count($users)==1) | |
| { | |
| $user_id = $users[0]->ID; | |
| //Update Status Switcher to True if match | |
| update_user_meta( $user_id, 'status', 'true' ); | |
| echo "User activated successfully!"; | |
| } | |
| else{ | |
| echo "Invalid Request, user not found"; | |
| } | |
| }, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment