Created
November 24, 2020 08:51
-
-
Save Neshable/6572ad5897efdaa81ee3491b4bfba294 to your computer and use it in GitHub Desktop.
Manually verify all unverified users. Works with this plugin - https://wordpress.org/plugins/user-registration/, but can me modified to work with others as well.
This file contains 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
/** | |
* Manually verify all unverified users | |
* | |
* @return bool | |
*/ | |
function verify_all_users() { | |
// Get only user IDs for unverified users | |
$user_query = new WP_User_Query( array( | |
'fields' => 'ID', | |
'meta_key' => 'ur_confirm_email', | |
'meta_value' => 0, | |
'meta_compare' => '=' // exact match only | |
) ); | |
// User Loop | |
if ( ! empty( $user_query->get_results() ) ) { | |
foreach ( $user_query->get_results() as $user_id ) { | |
// Will return false if the previous value is the same as $new_value. | |
$updated = update_user_meta( $user_id, 'ur_confirm_email', 1 ); | |
} | |
return true; | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment