UsersWP Pending Activation Setup
November 14, 2024 ยท AI Conversations
### Method 1: Using UsersWP Settings (Built-in Feature)
1. **Navigate to UsersWP Settings**:
– Go to your WordPress dashboard.
– Click on **UsersWP** > **General**.
2. **Enable Email Verification**:
– Look for the **"Email Verification"** option.
– Enable it to require users to verify their email addresses before they can activate their accounts.
3. **Pending Activation**:
– When a new user registers, their account will be in a "Pending" status until they verify their email.
– You can customize the **email content** under **UsersWP** > **Emails**.
4. **Manual Admin Approval (if needed)**:
– If you want manual approval by the admin, you can enable the **"Admin Approval"** option. This will put users in a pending state until an admin approves their registration.
### Method 2: Programmatically Set Users to Pending Activation
If you need more control, such as automatically setting users to a "pending activation" status using custom code, you can hook into **UsersWP actions and filters**.
Here's an example of how to set users to a pending activation status upon registration:
// Add this code to your theme's functions.php or a custom plugin
add_action('uwp_after_register_user', 'set_user_pending_activation', 10, 2);
function set_user_pending_activation($user_id, $userdata) {
// Update user status to 'pending'
update_user_meta($user_id, 'account_status', 'pending');
// Optionally, send an email notification to admin
wp_mail(get_option('admin_email'), 'New User Pending Activation', 'A new user has registered and is pending activation.');
}
### Explanation:
– The **`uwp_after_register_user`** hook runs after a new user registers.
– The function sets the user's status to **'pending'**.
– You can modify the meta key `'account_status'` based on your needs.
### Method 3: Using UsersWP Shortcodes (Restrict Content)
If you have specific pages or content that should only be accessible to **active users**, you can use the built-in **UsersWP shortcodes** like:
[uwp_is_active]Content for active users only[/uwp_is_active]
[uwp_is_pending]Content for pending users only[/uwp_is_pending]
These shortcodes help you control which users can access certain content based on their status.
Let me know if you need further customization or if there's a specific feature you're looking to implement!