Home › Forums › Legacy Support › Support queries › Other issues › Redirect to Registration if not member
Tagged: membership, redirect, wordpress
- This topic has 22 replies, 2 voices, and was last updated 5 years, 6 months ago by Jim.
-
AuthorPosts
-
October 1, 2018 at 7:28 pm #178429JimSpectatorHi 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?October 1, 2018 at 7:29 pm #178430JimSpectatorThis reply has been marked as private.October 3, 2018 at 2:01 pm #178581Anshuman SahuKeymasteryup 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 idOctober 3, 2018 at 11:55 pm #178636JimSpectatorHi 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....October 4, 2018 at 2:38 pm #178760Anshuman SahuKeymasterplease 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 .October 4, 2018 at 4:25 pm #178770JimSpectatorThis reply has been marked as private.October 5, 2018 at 2:43 pm #178917Anshuman SahuKeymasterThis reply has been marked as private.October 5, 2018 at 4:30 pm #178930JimSpectatorHi 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 pageOctober 6, 2018 at 9:09 am #179000Anshuman SahuKeymasterIm 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 ?October 6, 2018 at 9:09 am #179001Anshuman SahuKeymasteraccording 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 .October 6, 2018 at 3:23 pm #179049JimSpectatorHi 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?October 8, 2018 at 2:49 pm #179204Anshuman SahuKeymasterThis reply has been marked as private.October 8, 2018 at 8:59 pm #179237JimSpectatorHi 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. ThanksOctober 9, 2018 at 2:23 pm #179353Anshuman SahuKeymasterWell 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 .October 9, 2018 at 5:37 pm #179393JimSpectatorThis 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
-
AuthorPosts
- The topic ‘Redirect to Registration if not member’ is closed to new replies.