Redirect to Registration if not member

Home Forums Legacy Support Support queries Other issues Redirect to Registration if not member

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #178429
    Jim
    Spectator
    Hi there, I'm trying to redirect the users to registration page if they choose a membership when not logged. For example people go to plans page, press "Select" and the page xxx/membership-checkout/ will detect if he is logged to checkout or if not redirect to registration. The problem is that the code is redirecting the plans page and checkout (both), not only checkout..... I've tried a couple things and never work and I can't find any plugin.. I'm using a pricing table plugin and the "Select" is the link to that checkout plan like xxx/membership-checkout/?level=1 I used this code in functions.php (child theme):   function redirect_to_reg() { if ( is_page('membership-checkout') && !is_user_logged_in() ) { wp_redirect( site_url( '/register' ) ); exit; } } add_action( 'template_redirect', 'redirect_to_reg' );   Can you help please?
    #178430
    Jim
    Spectator
    This reply has been marked as private.
    #178581
    Anshuman Sahu
    Keymaster
    yup you are in right direction . There is no such unique template to check if its a memberhsip checkout page . you will need to note down the page id and use this code instead :     function redirect_to_reg() { if ( is_page(45) && !is_user_logged_in() ) { wp_redirect( site_url( '/register' ) ); exit; } } add_action( 'template_redirect', 'redirect_to_reg' );   where 45 is the page id
    #178636
    Jim
    Spectator
    Hi there, This code was the same I had and tested but don't work, it is still redirecting the Membership plans page. I just don't want allow people to checkout without having an buddypress account, since I cannot merge them....
    #178760
    Anshuman Sahu
    Keymaster
    please share : site url , admin credentials and a valid ftp credentials to check and fix up this on your site . PS : mark reply as private while sharing .
    #178770
    Jim
    Spectator
    This reply has been marked as private.
    #178917
    Anshuman Sahu
    Keymaster
    This reply has been marked as private.
    #178930
    Jim
    Spectator
    Hi there,   Login, check the plans page and check code. If you notice according code the plans page MUST show and only redirect the next page, the checkout page, got it?   But it's redirecting both and people must be able to see plans before be redirected to registration page
    #179000
    Anshuman Sahu
    Keymaster
    Im sorry Im not able to get you and neither your code , can you please tell your exact requirement , what exactly you are trying to do here ?
    #179001
    Anshuman Sahu
    Keymaster
    according to code if user is not logged in and is on levels page she will be redirected. for logged in users she will not be redirected .
    #179049
    Jim
    Spectator
    Hi there, According my code VISITOR should be ONLY redirected IF it's on Memberships Pro checkout page BUT you are getting redirected on Memberships Plans page too, got it?
    #179204
    Anshuman Sahu
    Keymaster
    This reply has been marked as private.
    #179237
    Jim
    Spectator
    Hi there, I fixed that by deactivating the Membership Plans page on Memberships Pro settings. But I have an issue, if you go to the course (after login) and try to Take the course you will see that the button don't work, you choose the Pricing options but nothing happens. How can I force this to go to the plans page?   Please advise since this will be the only way for us to work with this.   Thanks
    #179353
    Anshuman Sahu
    Keymaster
    Well for that user has to select the pricing and then they have to click on the take this course button . and you would need to disable the "Open Login popup for non logged in users when they click on take this course button(For all courses)"  form wp-admin -> lms -> settings .  
    #179393
    Jim
    Spectator
    This will not work because after I deactivate the checkboxes, when I click on the button nothing happens too, not even redirects to Plans page. Can I hardcode in some way IF the user is not a member (paid) then redirect to plans page? With this I can even deactivate the force login
Viewing 15 posts - 1 through 15 (of 23 total)
  • The topic ‘Redirect to Registration if not member’ is closed to new replies.