Question

Trigger the Login or Registration pop-up modal from any HTML link

  • 29 March 2024
  • 6 replies
  • 55 views

Userlevel 1

I randomly discovered that you could do this while optimising some of the code for our own community. I thought it was a good enough tip to share with all of you. If you’ve got any HTML element that you can freely control then wrap your link with the following code.

Triggering the modal to show at the login page:

<a class="loginmodal-link js-open-modal qa-register-have-account-link" data-modal="login" data-mn="ItemView" data-mn-app="frontend">Name of link here</a>

Triggering the modal to show at the registration page:

<a class="loginmodal-link js-open-modal qa-register-have-account-link" data-modal="register" data-mn="ItemView" data-mn-app="frontend">Name of link here</a>

Hope this helps!


6 replies

Userlevel 5
Badge +1

Coincidentally, I was trying to add a link to the registration or login page inside a Community post today. I guess that doesn't really work with this code, does it?

Userlevel 1

@Jef Vanlaer - Not that i’m aware of. I don’t think you can add classes to URLS on posts without adding some custom javascript in there to catch the URLs dynamically. The only alternative is to directly link to your registration page using:

https://change-me.com/member/register

 

Userlevel 5
Badge +1

@Samuel Brown It seems like that url doesn't exist on our community:

 

Userlevel 1

@Jef Vanlaer - My bad! It’s member not member(s) in the URL. I’ve adjusted the original comment to reflect this.

Userlevel 5
Badge +1

@Samuel Brown Awesome! It also works with /login apparently, so this fully solves my use case 👍

Userlevel 5
Badge +4

This is an awesome tip @Samuel Brown - thank you for sharing it!

Reply