How to implement post-signup custom logic in a login/redirect system? Answered
Hi All,
Does anyone know a way to insert custom code into the login/ redirect functionality?
So my site has a member dashboard the information on which is specific to each user - using the attributes. But each user also has a forward-facing profile page, which a specific slug based on their name. I want to write some simple code that redirects the user to their public facing page on login. I have those specific urls stored in a ‘slug’ custom attribute, which I link to on the front-end of site using ms-code-field-link - however I need to redirect to those slugs after login as well.
All help appreciated.
Comments
9 comments
Hi Karina, have you checked out this feature?
https://docs.memberstack.com/hc/en-us/articles/7385311945499
It might be what you're looking for without the need for custom code.
Hi Tyler, Yes, the member-specific login is the functionality I need, however, I don’t want my clients to have to manually input a specific redirect everytime a new member joins. I need that to be programmatic.
How are you programmatically setting the login redirect via custom field now?
Are you doing that through Make or Zapier, etc?
I’m not. It’s currently redirectly members to their dashboards, but I want it to redirect to their public profile page. I also don’t want to use Make or Zapier to achieve this. The custom code needed is super simple, I just need to work out where to put it.
Right now we don't have any sort of post login or signups hooks.
So we'll need to get a bit creative. Here's what I recommend.
Create a page that you can use as the login redirect - all members will be redirected to this page at first.
Add custom code to that page that immediately redirects them to the correct page. The logic that does the redirect should be nearly instant, but you could always add a loader to the page.
Yeah that’s what I was meandering towards… thanks
How do I call custom code on after signup is successful?
Hey Disha Jain, I am not sure about the use-case you are trying to solve.
But in case you want to run a script after a user signs up, you can place the script on the page the users land on after they signup, like onboarding or any page for that matter.
If you are trying to achieve something else specifically, you can share more about your use-case, so that I can understand better.
This might be overkill, but you could take over the sign up flow all together using the DOM package. Then you have more control over what happens when https://developers.memberstack.com/docs/dom-front-end-package
Please sign in to leave a comment.