button redirect to different page for logged in visitors

Home Forums Legacy Support Support queries Setup issues button redirect to different page for logged in visitors

Viewing 15 posts - 1 through 15 (of 44 total)
  • Author
    Posts
  • #372948
    MeesterGijs
    Spectator
    Hello, 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, Gijs
    #372994
    Veronica
    Moderator
    hi for that we need to check please ping us here tomorrow
    #373066
    MeesterGijs
    Spectator
    And?
    #373146
    Veronica
    Moderator
    hi 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
    });
    
    #373242
    MeesterGijs
    Spectator
    This reply has been marked as private.
    #373331
    Veronica
    Moderator
    This reply has been marked as private.
    #373403
    MeesterGijs
    Spectator
    That'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?
    #373509
    Veronica
    Moderator
    can you give me access to the plugin editor so I can check the same you can provide for the staging site
    #373550
    MeesterGijs
    Spectator
    This reply has been marked as private.
    #373740
    Veronica
    Moderator
    check 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
        }
    });
    #373917
    MeesterGijs
    Spectator
    OMG! 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 closing
    #373971
    Veronica
    Moderator
    just 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.php
    #374199
    MeesterGijs
    Spectator
    On 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..
    #374258
    MeesterGijs
    Spectator
    It 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?
    #374315
    MeesterGijs
    Spectator
    Sorry, 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!
Viewing 15 posts - 1 through 15 (of 44 total)
  • The topic ‘button redirect to different page for logged in visitors’ is closed to new replies.