Adding user registration verification for WordPress
By default, WordPress allows new users to register immediately after filling out the registration form. To prevent spam accounts and ensure authenticity, you can add email verification so that users must confirm their email address before accessing your site. On ruachost.com, this can be done using plugins or custom code.
Why Add Registration Verification?
Section titled “Why Add Registration Verification?”- Prevents spam and fake accounts.
- Ensures only valid email addresses are used.
- Improves site security and user trust.
- Helps maintain a clean user database.
Method 1: Using a Plugin (Recommended)
Section titled “Method 1: Using a Plugin (Recommended)”-
Log in to WordPress as administrator.
-
Go to Plugins → Add New.
-
Search for User Verification or WP Email Verification.
-
Click Install Now, then Activate.
-
In the dashboard, go to Settings → User Verification.
-
Configure options:
- Enable email verification for new registrations.
- Customize the verification email template.
- Set the redirect page after successful verification.
-
Save changes.
✅ New users will now receive a verification email with a link they must click before logging in.
Method 2: Custom Code (Advanced)
Section titled “Method 2: Custom Code (Advanced)”If you prefer not to use a plugin, you can add verification manually:
- Hook into the
user_registeraction in your theme’sfunctions.php. - Generate a unique verification token and send it via email.
- Store the token in user meta data.
- Create a verification page that checks the token and activates the account.
Example snippet (simplified):
function send_verification_email($user_id) { $user = get_userdata($user_id); $token = wp_generate_password(20, false); update_user_meta($user_id, 'email_verified', 0); update_user_meta($user_id, 'verification_token', $token);
$verification_link = site_url("/verify?token=$token&user=$user_id"); wp_mail($user->user_email, "Verify Your Account", "Click here: $verification_link");}add_action('user_register', 'send_verification_email');Important Notes
Section titled “Important Notes”- Always back up your site before adding custom code.
- Test verification emails to ensure they are delivered (check spam folder).
- Use SMTP plugins (like WP Mail SMTP) for reliable email delivery.
- Consider adding CAPTCHA to further reduce spam registrations.