Forum Replies Created

Viewing 1 replies (of 1 total)
  • Thread Starter bartthe1st

    (@bartthe1st)

    Thank you Chad!

    If anybody is interested as well:
    I created a functions.php in my child-theme-folder and added:

    <?php
    // Redirects specified url to the login page.
    /*
     * This example makes use of wpmem_current_url() to get the url of the 
     * page the user is currently requesting. See documentation here:
     * https://rocketgeek.com/plugins/wp-members/docs/api-functions/wpmem_current_url/
     */
    add_action( 'template_redirect', 'my_redirect_to_login' );
    function my_redirect_to_login() {
      if ( ! is_user_logged_in() && wpmem_current_url() == site_url( '/pagename/' ) ) {
    	  wpmem_redirect_to_login();
      }
      elseif ( ! is_user_logged_in() && wpmem_current_url() == is_single() ) {
      	wpmem_redirect_to_login();
      }
      return;
    }

    Now the redirect is supposed to be in action, if the user is not logged in and wants to access the page “pagename” or any blog post.

Viewing 1 replies (of 1 total)