Okay
  Public Ticket #3650955
How to adjust bit of code?
Closed

Comments

  •  12
    MeesterGijs started the conversation

    Hi Alex,

    How are you?

    I have this bit of code, but I use a different button now and I just can't get the code to work? It's for this button at the homepage: https://imgur.com/a/NUBzN5C How do I change code so that it works?

    add_action('wp_footer',function(){
        ?>
       <script>
       window.addEventListener("load", (event) => {
       if(typeof localforage !=='undefined'){
       localforage.getItem('bp_login_token').then(function(token){
            if(token){
    if(document.querySelector('.home a.elementor-button elementor-button-link elementor-size-sm'))
            document.querySelector('.home a.elementor-button elementor-button-link elementor-size-sm').setAttribute('href','https://meestergijs.nl/app/#component=course');
            }else{
    if(document.querySelector('.home a.elementor-button elementor-button-link elementor-size-sm'))
            document.querySelector('.home a.elementor-button elementor-button-link elementor-size-sm').setAttribute('href','https://meestergijs.nl/aanmelden/');
            }
        })
       }
        });
       </script>
        <?php
    });


  • [deleted] replied

    add classes to your button and use them please do not use elementor calsses elementor provides option to add custom class to button.

  •  12
    MeesterGijs replied

    Let's say my CSS class is: startmetoefenen, where do I add that in Elementor?

    And then how do I incorporate that class in the code shared below? Because I can't get it to work..

  • [deleted] replied

    please use this code then : 

    add_action('wp_footer',function(){
        ?>
       <script>
       window.addEventListener("load", (event) => {
       if(typeof localforage !=='undefined'){
       localforage.getItem('bp_login_token').then(function(token){
            if(token){
    if(document.querySelector('.home a.startmetoefenen'))
            document.querySelector('.home a.startmetoefenen').setAttribute('href','https://meestergijs.nl/app/#component=course');
            }else{
    if(document.querySelector('.home a.startmetoefenen'))
            document.querySelector('.home a.startmetoefenen').setAttribute('href','https://meestergijs.nl/aanmelden/');
            }
        })
       }
        });
       </script>
        <?php
    });-->
  •  12
    MeesterGijs replied

    Hi Alex, it doesn't seem to work.

    Could you check if I need to change something in Elementor perhaps? You still have credentials?

    Gijs


    Note to self: I save my old code here.

    add_action('wp_footer',function(){
        ?>
       <script>
       window.addEventListener("load", (event) => {
       if(typeof localforage !=='undefined'){
       localforage.getItem('bp_login_token').then(function(token){
            if(token){
    if(document.querySelector('.home a.elementor-button-link.elementor-size-ms'))
            document.querySelector('.home a.elementor-button-link.elementor-size-ms').setAttribute('href','https://meestergijs.nl/app/#component=course');
            }else{
    if(document.querySelector('.home a.elementor-button-link.elementor-size-ms'))
            document.querySelector('.home a.elementor-button-link.elementor-size-ms').setAttribute('href','https://meestergijs.nl/aanmelden/');
            }
        })
       }
        });
       </script>
        <?php
    });



  • [deleted] replied

    that button does not have the class " startmetoefenen " please add that class to that button  to fix the issue 

  •  12
    MeesterGijs replied

    Still doesn't work.

    I think I'll change it two buttons: LOGIN, REGISTER. What is the url for the login page? Because url/#login doesn't work... and /inloggen doesn't neither.

  • [deleted] replied

    no class seen on the button actually : 

    6121819131.png


  •  12
    MeesterGijs replied

    Correct. I have changed my mind. As said in my previous reply: What is the correct url for the login page?

  • [deleted] replied

    Im sorry Im not able to understand your query , do you mean this url ? : 

    https://meestergijs.nl/app

  •  12
    MeesterGijs replied

    Yes, but I want the login screen to be shown like this:  https://imgur.com/a/0IMxOJ1


  • [deleted] replied

    hi im sorry that is not possible as of now.

  •  12
    MeesterGijs replied

    Ok, understood. Thanks