Blocking the login for pending activation

In the registration process, we set the activation status as Pending Activation. However, this value doesn't have any effect until we use it and allow or block the user from logging in. In step 5, we used the wp_authenticate_user filter with a callback function called wpccp_chapter5_login_validation.

wp_authenticate_user: This action is executed in the user login process to apply additional validations before authenticating the user.

Inside the function, we first check whether the proper user ID is set. Then, we retrieve the activation status from the wp_usermeta table by using the wpccp_user_activation_status key we used in the registration process. When the user has a pending activation, we use a WP_Error class to generate and return a custom error message called Account is pending activation. So, the user login will be blocked due to the error, and the custom message will be displayed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset