Forked from kimwhite/stop_users_from_logging_in_pmpro.php
Created
November 23, 2022 14:04
-
-
Save andrewlimaza/e20de0718c29bf3fa6b28176c1f80a9c to your computer and use it in GitHub Desktop.
Stop users from logging in if they are not validated (PMPro Email Confirmation)
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
<?php | |
/** | |
* This function will stop any user's that aren't validated from logging into your WordPress website. | |
* This requires PMPro Email Confirmation - https://www.paidmembershipspro.com/add-ons/email-confirmation-add-on/ | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
* Visit https://paidmembershipspro.com for further assistance. | |
*/ | |
function pmpro_check_login( $user, $password ) { | |
$validated = get_user_meta( $user->ID, "pmpro_email_confirmation_key", true ); | |
if( $validated != 'validated' && !empty( $validated ) ) { | |
return new WP_Error( 'user_not_verified', 'User has not validated their email' ); | |
} | |
return $user; | |
} | |
add_filter( 'wp_authenticate_user', 'pmpro_check_login', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment