SamNZ Posted February 24, 2022 Report Share Posted February 24, 2022 Hi, My App has two suer types - Host and Businesses, at login I want to redirect each user to a different webpage where they will have access to different data pages. I also want to create a condition whereby if they have completed set up, they will be directed to the main homepage for that user, and if they have they will be directed to a setup page to complete set up. My initial Authorization Table contains three data sets to help me achieve this: User Type: Host/Business - (Drop Down in Data page) Set Up Complete Host: Yes/No - Hidden Set Up complete Business Yes/No - Hidden. I have amended the following script to try and work but its not working: <script> } else if ("[@authfield:membership_type]" == "Business") && ([@authfield:business_set_up_complete]" == "No") { window.location = "https://www.test.com/business-set-up/"; } } else if ("[@authfield:membership_type]" == "Business") && ([@authfield:business_set_up_complete]" == "Yes"){ window.location = "https://www.test.com/business-home.html"; } else if ("[@authfield:membership_type:host]" == "Host") && ([@authfield:business_set_up_complete]" == "No") { window.location = "https://www.test.com/host-set-up/"; } else if ("[@authfield:membership_type:host]" == "Host") && ([@authfield:business_set_up_complete]" == "No") { window.location = "http://www.test.com/host-home.html"; } </script> Quote Link to comment Share on other sites More sharing options...
Kurumi Posted February 25, 2022 Report Share Posted February 25, 2022 Hi @SamNZ - may you please try this: <script> if ("[@authfield:membership_type]" == "Business") && ("[@authfield:business_set_up_complete]" == "No") { window.location = "https://www.test.com/business-set-up/"; } else if ("[@authfield:membership_type]" == "Business") && ("[@authfield:business_set_up_complete]" == "Yes"){ window.location = "https://www.test.com/business-home.html"; } else if ("[@authfield:membership_type:host]" == "Host") && ("[@authfield:business_set_up_complete]" == "No") { window.location = "https://www.test.com/host-set-up/"; } else if ("[@authfield:membership_type:host]" == "Host") && ("[@authfield:business_set_up_complete]" == "No") { window.location = "http://www.test.com/host-home.html"; } </script> There seems to be missing quotes in your code and unexpected identifier. Here's a reference: https://howto.caspio.com/tech-tips-and-articles/common-customizations/create-user-specific-redirect-after-login/ Quote Link to comment Share on other sites More sharing options...
PotatoMato Posted February 26, 2022 Report Share Posted February 26, 2022 Hi! Just to add you can also check this Youtube tutorial: Quote Link to comment Share on other sites More sharing options...
SamNZ Posted March 2, 2022 Author Report Share Posted March 2, 2022 Thanks you so much, really helpful. Okay so I think I need t set up my views, and change the user type to yes no questions, but my problem is to keep it clean for my users, I need to them to be able to select one of the other, creating two users both with Yes No questions creates the ability to select both user types as yes, which I do not want, then if I just base it on one yes no questions, i can only have one user type in my form, ie Host Yes/No, so if its no they are a business user, but I cant create a selectable option for Businesses so it will be confusing. The Caspio tutorial works well if someone else is signing people, ie: the admin, not if you want people to sign themselves up, or is there a trick here I am missing? Quote Link to comment Share on other sites More sharing options...
SamNZ Posted March 2, 2022 Author Report Share Posted March 2, 2022 Or can i use unique fields as I have done in my original code using a drop down to ensure consistency? Does it matter if its not a yes/no field? Quote Link to comment Share on other sites More sharing options...
SamNZ Posted March 2, 2022 Author Report Share Posted March 2, 2022 Okay so I now have Yes/No for Both Host and Business by creating a rule that disables the other if one is selected. Quote Link to comment Share on other sites More sharing options...
SamNZ Posted March 2, 2022 Author Report Share Posted March 2, 2022 Maybe its just me, but the user interface seems different, has Caspio changed since this was created in 2014? Ive created views based on: user type selected accoutn active Set Up complete but when i goto authentications, it doesn't give me the options of using these views? Quote Link to comment Share on other sites More sharing options...
kpcollier Posted March 2, 2022 Report Share Posted March 2, 2022 @SamNZ You don't need to use yes/no fields. You can use whatever you want, really, for the redirections. Personally, I would keep Membership Type as a text(255), so that the user can select either Business or Host. Then, if you need to in the future, you can expand that with more options much more easily than you would if you were using a Yes/No field for every role. Then, for business_set_up_complete, you could either use text(255), or if the only options are Yes and No, then you can use the yes/no field. The redirection script can be changed to fit your needs, but the one that @Meekeee shared should work for how you first had it set up (I do not think it will work if you change all fields to Yes/No). Then, in your submission form for creating user profiles, you would have a dropdown or radio buttons to select which Membership Type. I'm not sure if you are letting the users state that their business set up is complete or if you are calculating that yourself, but if they do then you can either make that a checkbox or radio buttons too so. Now you have the data you need for the login redirections. Quote Link to comment Share on other sites More sharing options...
kpcollier Posted March 2, 2022 Report Share Posted March 2, 2022 Just now, SamNZ said: Maybe its just me, but the user interface seems different, has Caspio changed since this was created in 2014? Ive created views based on: but when i goto authentications, it doesn't give me the options of using these views? The answer to both of these can be found in the how to site. https://howto.caspio.com/ I highly, highly recommend looking through this as it can help you tremendously when first starting. You can find changes in the Release Notes section and how to use views in authentications in the Authentication section. Quote Link to comment Share on other sites More sharing options...
kpcollier Posted March 2, 2022 Report Share Posted March 2, 2022 Also, you don't need to make views for the roles for redirection. You can just use your User Table. The javascript is doing the filtering with the two conditions set already. You need the full datasource for the redirections to work. i.e., if you set the datasource to Host_View, then your Business members won't be included in the datasource, so they won't be able to log in. Quote Link to comment Share on other sites More sharing options...
SamNZ Posted March 2, 2022 Author Report Share Posted March 2, 2022 Thanks so much, Ill follow your instructions and report back. Quote Link to comment Share on other sites More sharing options...
SamNZ Posted March 2, 2022 Author Report Share Posted March 2, 2022 So it still wouldnt work, so i tweaked it to test the host and business parameters and this worked, <script> if ("[@authfield:membership_type]" == "Business"){ window.location = "https://test.com/business-homepage/"; } else if ("[@authfield:membership_type:host]" == "Host") { window.location = "https://test.com/host-homepage/"; } </script> I wonder if its the "&&" feature or the Yes/No.... Quote Link to comment Share on other sites More sharing options...
SamNZ Posted March 2, 2022 Author Report Share Posted March 2, 2022 Got it, thanks so much, needed the " )( " taken out int he middle of each line script to keep all the elements together kpcollier 1 Quote Link to comment Share on other sites More sharing options...
kpcollier Posted March 2, 2022 Report Share Posted March 2, 2022 18 minutes ago, SamNZ said: I wonder if its the "&&" feature or the Yes/No.... One thing to keep in mind with Yes/No fields is that Caspio doesn't treat the values the same in all instances. Sometimes Yes and No equal 1 and 0, sometimes Y and N, sometimes Yes and No. If whatever you are doing isn't working in the future, try the different value types just in case. Don't know why they don't keep it uniform throughout. Quote Link to comment Share on other sites More sharing options...
Kronos Posted October 20, 2023 Report Share Posted October 20, 2023 Hi, if you want to redirect users if they are using mobile or desktop you may try this solution: I hope this helps! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.