<?php /* Plugin Name: WP-Members utility: set all users as confirmed Plugin URI: https://test.rocketgeek.com Version: 1.0.0 Author: Chad Butler Author URI: https://butlerblog.com/ Text Domain: wp-members Domain Path: /i18n/languages/ License: GPLv3 */ /**login-link * A drop-in code snippet to set all users on the site as * "validated" (when using the plugin's account confirmation * setting). All existing users on the site will be set as * validated without affecting passwords and no email will be sent. * * To Use: * 1. Save the code snippet to your theme's functions.php * 2. Go to Tools > Confirm All Users. * 3. Follow prompts on screen. * 4. Remove the code snippet when completed. */ add_action( 'init', 'confirm_all_users_init' ); function confirm_all_users_init() { global $wpmem; $wpmem->confirm_all_users = New My_Confirm_All_Users_Class(); } class My_Confirm_All_Users_Class { function __construct() { add_action( 'admin_menu', array( $this, 'admin_menu' ) ); } function admin_menu() { $hook = add_management_page( 'Confirm All Users Page', 'Confirm All Users', 'edit_users', 'confirm-all-users', array( $this, 'admin_page' ), null ); add_action( "load-$hook", array( $this, 'admin_page_load' ) ); } function admin_page_load() { global $confirm_all_complete; $confirm_all_complete = false; if ( isset( $_GET['page'] ) && 'confirm-all-users' == $_GET['page'] && isset( $_POST['confirm-all-confirm'] ) && 1 == $_POST['confirm-all-confirm'] ) { $users = get_users( array( 'fields'=>'ID' ) ); foreach ( $users as $user_id ) { update_user_meta( $user_id, '_wpmem_user_confirmed', time() ); } $confirm_all_complete = true; } } function admin_page() { global $confirm_all_complete; echo "<h2>Confirm All Users</h2>"; if ( $confirm_all_complete ) { echo '<p>All users were confirmed.<br />'; echo 'You may now remove this code snippet if desired.</p>'; } else { $form_post = ( function_exists( 'wpmem_admin_form_post_url' ) ) ? wpmem_admin_form_post_url() : ''; echo "<p>This process will mark all existing user accounts as confirmd in WP-Members.<br />It will not change any passwords or send any emails to users."; echo '<form name="confirm-all-users" id="confirm-all-users" method="post" action="' . $form_post . '">'; echo '<p><input type="checkbox" name="confirm-all-confirm" value="1" /><label for="confirm-all-confirm">Confirm all users?</label></p>'; echo '<p><input type="submit" name="submit" value="Submit" /></p>'; echo '</form>'; } } } // End of My_Confirm_All_Users_Class
Not sure what to do with this code?
You're not a "coder" and don't know what to do? Don't worry! Code Snippets are the basic building blocks of WordPress customization, and once you know the basics, they are simple to use.
Here are some free articles to get you started:
- Using Code Snippets from the Site
- The functions.php File
- Create a plugin file for custom functions
- Create a child theme
- Do not modify plugin files!
For "hands on" help, consider a plugin support subscription or the Pro Bundle.