BuddyDev

Search

[Resolved] Branded login script

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #49430

    Hi Brajesh,

    I was trying to improve user experience when trying to login with the branded login plugin by providing user feedback after clicking the login button but I dont know why this script is not working.

    The (Loading…) text is not being displayed after clicking the login button

    function klein_login_form_js() {
      if ( !is_user_logged_in() && (is_page(28880) || is_page(33424)) ) { // Only load the script on specific pages with the login shortcode
        ?>
        <script id="klein-login-form-script" type="text/javascript">
          document.addEventListener("DOMContentLoaded", function() {
            var form = document.getElementById("loginform");
            if (form) {
              form.addEventListener("submit", function() {
                var submitBtn = document.getElementById("bl-login-submit");
                if (submitBtn) {
                    submitBtn.disabled = true;
                    submitBtn.value = "Loading...";
                    submitBtn.setAttribute("disabled", "disabled");
                }
              });
            }
          });
        </script>
        <?php
      }
    }
    add_action( 'wp_footer', 'klein_login_form_js' ); 

    Thanks

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #49431

    please note that I changed the button ID from wp-submit to bl-login-submit in my child theme

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #49438

    Hi Tosin,
    Please check page source to confirm that the script is added to the page.
    if it is added, you should remove the callback attachment to DOMContentLoaded event and call it directly as it is in the footer.

    Those 2 seems like obvious reasons. After that we can investigate the id etc if needed.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #49477

    This is now resolved there was another popup login form in the same page with similar form ID

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #49493

    Thank you Tosin.
    That’s good to know!

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: resolved