Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Chad Butler

    (@cbutlerjr)

    There is a function in the plugin that you can use for this. However, there are some caveats I will give you first.

    This function is not yet documented because it is considered still in development. With that in mind, there may be some changes in future updates, so if you use the function directly, you’ll need check updates for changes. When it is considered completed, that will be noted in the changelog for that release at which point you can ignore everything I just said.

    The function is wpmem_redirect_to_login() and it is currently located in /inc/core.php.

    This function can be used directly to redirect a user from a page that is blocked to a defined login page. If used directly, it needs to be hooked to an early action since you cannot redirect a user once content is sent to the browser. template_redirect is a good choice because it occurs early enough to redirect, but late enough that information is available about the content.

    You will need to have a login page defined in the plugin’s options.

    To use it directly, add the following to your functions.php:

    add_action( 'template_redirect', 'my_login_redirect' );
    function my_login_redirect() {
    	wpmem_redirect_to_login();
    }

    The planned development for this function is to accept some exclusions and perhaps some other arguments. It may also make it into the plugin’s options panel at some point.

    Thread Starter jgmotiv123

    (@jgmotiv123)

    Thank you so much for your thorough reply. As someone not well versed in code, where exactly should I paste the snippet below?

    add_action( ‘template_redirect’, ‘my_login_redirect’ );
    function my_login_redirect() {
    wpmem_redirect_to_login();
    }

    I opened the WordPress editor and pasted it into the functions.php file, but the site then wouldn’t load and issued an error warning.

    Plugin Author Chad Butler

    (@cbutlerjr)

    I opened the WordPress editor and pasted it into the functions.php file, but the site then wouldn’t load and issued an error warning.

    It’s kind of hard to say what you did wrong without knowing what the warning message was. But the code there is valid, it should go in your child theme’s functions.php file.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Login Page’ is closed to new replies.