Skip to content

Instantly share code, notes, and snippets.

@moxet
Created June 17, 2023 06:31
Show Gist options
  • Save moxet/5ac641b90fec36df10eeb0403c97c602 to your computer and use it in GitHub Desktop.
Save moxet/5ac641b90fec36df10eeb0403c97c602 to your computer and use it in GitHub Desktop.
Activate User with Hook using JFB
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