Home › Forums › Legacy Support › Support queries › Setup issues › button redirect to different page for logged in visitors
- This topic has 43 replies, 3 voices, and was last updated 3 years ago by Veronica.
-
AuthorPosts
-
October 17, 2021 at 12:08 pm #372948MeesterGijsSpectatorHello, I have a button at the homepage that sends people to the registration page. Is it possible for already logged visitors to have this same button redirect to courses page? That's meestergijs.nl/cursusaanbod. Thanks, GijsOctober 18, 2021 at 1:35 pm #372994VeronicaModeratorhi for that we need to check please ping us here tomorrowOctober 19, 2021 at 8:17 am #373066MeesterGijsSpectatorAnd?October 20, 2021 at 7:15 am #373146VeronicaModeratorhi try to add this code in wplms-customizer.php
add_action('wp_enqueue_scripts',function(){ ?> <script> jQuery('a.ubtn-link.ult-adjust-bottom-margin.ubtn-left.ubtn-large').on('click', function(event) { if(is_user_logged_in()){ event.preventDefault(); var url = jQuery(this).data('target'); location.replace('https://meestergijs.nl/cursusaanbod/'); } }); </script> <?php });
October 21, 2021 at 8:47 am #373242MeesterGijsSpectatorThis reply has been marked as private.October 22, 2021 at 10:08 am #373331VeronicaModeratorThis reply has been marked as private.October 23, 2021 at 9:15 am #373403MeesterGijsSpectatorThat's weird. Unfortunately, it doesn't work when I try. I added the code in the customizer pluging php file and this is what happens, it just sends me to registration page, not meestergijs.nl/cursusaanbod: http://somup.com/cr60Q23abA Should I change something in the code? Delete other code? How come it worked on your end?October 25, 2021 at 1:31 pm #373509VeronicaModeratorcan you give me access to the plugin editor so I can check the same you can provide for the staging siteOctober 26, 2021 at 5:17 am #373550MeesterGijsSpectatorThis reply has been marked as private.October 28, 2021 at 12:41 pm #373740VeronicaModeratorcheck this code please:add_action('wp_enqueue_scripts',function(){ if(is_user_logged_in()){ ?> <script> jQuery('a.ubtn-link.ult-adjust-bottom-margin.ubtn-left.ubtn-large').on('click', function(event) { event.preventDefault(); var url = jQuery(this).data('target'); location.replace('https://meestergijs.nl/cursusaanbod/'); }); </script> <?php } });
November 1, 2021 at 9:48 am #373917MeesterGijsSpectatorOMG! It works! That's so great. Thanks a lot. It does seem to take more time to load my homepage? Is that correct? Anything we can do about that? Best way/place to add the code? It didn't work in wplms customizer plugin, but it did work in WPLMS Footer. Btw, can I use /* explanation */ in WPLMS Footer? That way I remember what the code is for ;) Gijs closingNovember 2, 2021 at 6:46 am #373971VeronicaModeratorjust checked it is also working from wplms-customizer.php and as it is restricting the first redirect and then redirect to the given path that's why there is a bit of delay https://www.w3schools.com/js/js_comments.asp http://www.tizag.com/javascriptT/javascriptcomment.phpNovember 7, 2021 at 1:54 pm #374199MeesterGijsSpectatorOn Friday I saw the code at the bottom of the footer. I had to delete the code from WPLMS Google Footer. Re-using the code didn't do anything. Once it worked the other way around; it would redirect non-logged in users. Could you have another look? i deleted the code..November 8, 2021 at 9:33 am #374258MeesterGijsSpectatorIt works again.. Hopefully the code won't show at the bottom of the footer. That happened a few days ago... That means there was an error in the code. Waas that because I used /* text here */ to remember what I used the code for? Cna you use /* text here */ in WPLMS Footer?November 8, 2021 at 6:48 pm #374315MeesterGijsSpectatorSorry, this is what I see at the bottom of the footer. When I delete the code from WPLMS/Footer, it's gone. How can I use this code without the error of showing the text in the footer of the page? Thanks! -
AuthorPosts
- The topic ‘button redirect to different page for logged in visitors’ is closed to new replies.