How to change redirect URL on empty fields submit

12 years 9 months ago - 12 years 9 months ago #169151 by railer
Hi CB,

I made a duplicate of mod_cblogin, called mod_cblogin2 to use for a specific purpose.

Problem:

If the user clicks the "Login" button when the Username and Password fields are empty, they get taken to a page displaying the default login fields.

How do I modify the mod_cblogin2.php code to keep the user on my new duplicate mod_cblogin2 login page?

Perhaps you could also include code recommendations for displaying a short text error message above the fields if the redirect kicks in, such as "Field entries required."

Thanks,
railer

Please Log in to join the conversation.

12 years 9 months ago #169152 by railer
My duplicate mod_cblogin2 module displays on an article page with this URL:

index.php?option=com_content&view=article&id=24&Itemid=76

I've noticed that the current redirect is going here:
index.php?option=com_comprofiler&task=login

And from what I can see, the code resembling the above is located around line 104:
if (preg_match( '/index.php\?option=com_comprofiler&task=confirm&confirmCode=|index.php\?option=com_comprofiler&task=login/', $return)) $return = "index.php";

Is this the line of code I need to modify, and if so, how?
If it isn't, then please advise what I need to change.

Thanks,
railer

Please Log in to join the conversation.

12 years 9 months ago #169255 by krileon
Why was a second copy of the login module necessary? Simply create a new copy of the module within module manager and move to whatever position you want. There's no need to duplicate the PHP and XML or anything of the sort. The login module posts to CBs login page. Without doing so the login can not happen. You can not change this as CB doesn't perform a redirect on failed login, it simply displays the page instead of performing the login. This can be reviewed further within the function login inside comprofiler.php.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

12 years 9 months ago #169261 by railer
Hi Kyle,

Thanks for your input. I needed the duplicate login because in my case, the purpose is for pre-registered users to claim their default membership, so I wanted to change the button text for this specific module to "Continue" instead of "Login". After pressing "Continue" they would be directed to the CB Subs upgrade option page.

I've got it all working except that if the login fails, it goes to the actual CB Login form, not my modified form.

How can I get it to stay on my version of the form, and not go to the original CB Login form?

Can this be done? It's not really a redirect, now that I think about it. What code can I change so that it stays on my version of the CB Login form (mod_cblogin2)?

Thanks,
railer

Please Log in to join the conversation.

12 years 9 months ago #169275 by krileon

How can I get it to stay on my version of the form, and not go to the original CB Login form?

You can't, as I've stated the module posts to the login page. On failed login to simply displays the login page instead of redirecting. It's not module specific either. I suppose you could edit your second login module, add a custom hidden input to send with the post, then in the login function of comprofiler.php check for that hidden input in $_POST.. if it's present then echo a javascript history.go(-1) or something of the sort.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.218 seconds

Facebook Twitter LinkedIn