• Resolved boblebad

    (@boblebad)


    Hi

    I’m trying to get my site to redirect non-members to the home page, when clicking on something in the menu or pasting an url in to the browser.

    This is the top of my child theme index.php:

    get_header(); ?>
    
    <?php get_template_part('page-parts/general-before-wrap');?>
    
    <?php if (pmpro_hasMembershipLevel() ) { ?>

    And at the end i have bin trying different ways to redicrect, but it does not work, with wp_redirect i get header error:

    <?php } else { ?> 
    
    <?php wp_redirect(site_url('/home')); exit; ?>
    
    <?php } ?>

    I tried include page too, but got error on missing file/page.

    What am i missing here ?

    All the best
    Carsten

    https://www.ads-software.com/plugins/paid-memberships-pro/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi. Thank you for using Paid Memberships Pro. Try using the following code gist todo the redirect:

    https://gist.github.com/strangerstudios/5913034#file-pmpro_customizations-php

    Let us know how this works for you. Thanks.

    Thread Starter boblebad

    (@boblebad)

    You’re welcome, i use it with the theme Sweet Date ??

    But i’m not sure where the code needs to go, and if i need to alter it ?

    When put in child theme functions.php, nothing happens, the same with the index.php.

    I’m not familiar with Sweet Date, but you can add that code to your active theme’s functions.php file or a customizations plugin as described here: https://www.paidmembershipspro.com/2012/08/create-a-plugin-for-pmpro-customizations/

    Thread Starter boblebad

    (@boblebad)

    Thank you for your reply messica ??

    At first i couldn’t get it to work, but then i read “Redirect users away from posts requiring membership with Paid Memberships Pro.”, i didn’t think of that before, cause when have bin trying to use them earlier under the Sweet Date theme, they didn’t work, they had no effect on restricting access to the pages – but now they work ??

    Question 1: Is this needed to get tick boxes working on the pages, or is this a theme issue ?

    Question 2: How is it possible to redirect to the registration form or any other page that is not a Paid memberships Pro page ?

    All the best
    Carsten

    As I mentioned in your other thread – (1)it sounds like there might be some incompatibilities with Sweet Date, and (2)you can redirect to any URL you want with that code. See the other post for more, I’m going to close this because we don’t need 2 topics about the same thing ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Non-member, redirect to home page ?’ is closed to new replies.