Skip to content

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.

  • Prevents spam and fake accounts.
  • Ensures only valid email addresses are used.
  • Improves site security and user trust.
  • Helps maintain a clean user database.
  1. Log in to WordPress as administrator.

  2. Go to Plugins → Add New.

  3. Search for User Verification or WP Email Verification.

  4. Click Install Now, then Activate.

  5. In the dashboard, go to Settings → User Verification.

  6. Configure options:

    • Enable email verification for new registrations.
    • Customize the verification email template.
    • Set the redirect page after successful verification.
  7. Save changes.

✅ New users will now receive a verification email with a link they must click before logging in.

If you prefer not to use a plugin, you can add verification manually:

  1. Hook into the user_register action in your theme’s functions.php.
  2. Generate a unique verification token and send it via email.
  3. Store the token in user meta data.
  4. 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');
  • 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.