Drupal Modify Login System - drupal

I'm newbie in drupal...
I have a drupal website, and i want to extend its login system - i've been looking around the code but end up with headache.
what i wan to do is:
I want to put additional hidden form inside any login form
create a session variable that will be used on login process (after user click submit) and then destroy the session after that.
extend the login validation system inside drupal based on point 1 & 2 above - so i need to to control if my extended validation is valid (and drupal validation is valid) then go to where? otherwise then go to where?
so with that I'll have my own login system + drupal login system
Is somebody ever try this before?
fyi: I'm using drupal 6
Thank you in Advance for helping me
And

To modify the login form, you will likely need hook_form_alter() and knowledge of the Form API
You can add additional elements to the login form, including hidden fields. Hidden can either mean hidden html form elements (<input type='hidden'/>) or values that are not output in the HTML at all but are stored server side for the corresponding validate and submit functions.
You can add additional functions to $form['#validate'] to change the login criteria (whether the login is accepted or not)
You can add additional functions to $form['#submit'] (note the '#') to add operations to perform after the user's login has passed validation. The default submit handler, user_login_submit(), simply redirects the user to their account page.

You should also consider checking http://drupal.org/project/logintoboggan . Logintoboggan is a module that tweaks and changes Drupal's default login by adding a lot of features. You can see how they achieved certain functionalities by reading the code. That will help you when you write your own code.

Related

Make Gravity Forms Hidden Field Required?

I have a Wordpress site that uses Gravity Forms, including hidden fields which are required for proper functionality. Is there a way to make hidden fields on forms built with gravity forms required?
I will be sending out an email with a URL linking to this form which auto-populates these hidden fields. However, I'd like to make these hidden fields required, or prevent the form being submitted if these hidden fields are not set, which may happen if a user navigates to the form manually instead of navigating to it via a generated URL.
I wish to avoid the perception that the form has been submitted when it has only been submitted with partial information.
The simplest, code-free solution would be to use conditional logic to only show the submit button if your hidden fields are not empty. Here's what the settings might look like:
You can take this a step further and use the opposite conditional logic to show an HTML field with a custom message letting the user know why they can't submit the form.
a hidden form element can't be required.
elements of type hidden let web developers include data that cannot be seen or modified by users when a form is submitted.
Source
If you put a hidden value, make sure you put it with a value to be sent or make sure that before submit, via javascript you edit that value.
You can now use two CSS classes to hide your field:
"gf_hidden" or "gf_invisible"
It won't show the Validation Message if it isn't filled though, so the user may not know what is missing from the submission:
The folk at Gravity Perks have a nice page explaining it in more detail though.
https://gravitywiz.com/how-to-hide-gravity-forms-product-fields/

Force anonymous to register before submitting a form. Drupal 7

I want to force anonymous to register an account before submitting the form.
So I have to allow permission for anonymous to access the form,
Then I use hook_form_FORM_ID_alter to edit form. Then I wanted to redirect submit button to another link if it is clicked by anonymous.(I still have no idea how to do it. It would be nice if anyone can tell me)
Is this the right solution?
For now,
I have a pop-up a login form (Modal forms and Facebook OAuth). In the form there is a register button. Then If user choose to register I want to keep the form that he have already input and show it after he confirm his email.
Thank you.
Off the top of my head, I would allow the form to be submitted either by an anonymous user or a registered one.
in my function MYMODULE_MYFORM_submit() I would check to see if the user is logged in.
If yes proceed as normal, if no, store the form, either in a temp SESSION variable or into a custom MySQL table and forward the user to login/register page (mysite.com/user) using drupal_goto('user')
once the user was registered you could then check for the existence of the form in the SESSION array or your MySQL table, and then carry on with the process as you would if the user had been logged in in the first place
Hope this makes sense or is of help

displaying the same content with loginview

I have an asp.net webpage that has user login enabled. Inside of my loginview controller I have my anonymous and loggedin code. Is it possible to have the same code in both, but for example just add a button in the loggedin view. All I want to do is when the user logs in display the same information except if logged in show a button, that is not shown when user is anonymous. Any help would be appreciated thank you. I already tried putting the same code into both anonymous and logged in but I get an error saying that a box already contains a definition for that name.
You can try reusing templates in code, as you can create your own template instance, but it really isn't worth the effort. It would be best to just copy the markup and change the ID's. I know it's a pain...
You get the naming conflict because it defines the template instance as a single instance, and each instance gets implemented in the control tree (even though it may not be rendered).

Convert HTML Forms to ASP.NET forms with a silent post and response handler

I want to write a DotNetNuke module that can take an HTML form and parse or transform it into an asp.net form that would then do a HTTPPost to the page specified in the HTML Form's action property.
We regularly run into the need to use pre-existing forms (from existing sites and Service Providers like Paypal and Constant Contact). Currently, we either use an IFrame, manually convert the form into an ASP.NET user control, or use a forms module to recreate the form. It seems like it should be fairly easy to create an automated way to handle these with ASP.NET.
My quick plan:
1.) Admin Users will paste the form into a settings page and then click a convert button
2.) The code will parse the HTML and generate a ascx User Control from it and store the posting address. We may just have to add runat="server" into each of the form controls
3.) The admin user will be able to specify a variety of response codes and corresponding messages. (i.e. 1 -> "Thank you for your Donation", 2-> "We were not able to process your request at this time due to ...")
Users would then fill out the form and hit submit. The system would get the names and values of all form controls and Silent Post that to the posting address and get the response code and then display the corresponding message.
Any thoughts or suggestions of the best way to do this? Are there any tools that already do this or would be helpful?
Thanks,
David O'Leary

Wrapping a web login page

I have a web login page with the standard username password and login button controls. I would like to write a wrapper page that will render and auto fill the username and login form text boxes with a constant and force the onclick event for login button. Any suggestions how to accomplish this?
If you want this sort of functionality to decrease overall testing time you should also take a look at:
WatiN
or
IEUnit
If you are doing this as a production feature of your system you should look at implementing some sort of "Remember Me" option with browser-based cookies - you would likely never want such a feature that automatically authenticates any anonymous person to a user to your system out in the wild.
Depending on the specific form and how it is done, you can make a wrapper page that embeds the form inside an iFrame. You can then use JS to set the values inside the iFrame, and call the proper submit.
This would require testing and a bit of research, but i have seen it done.
NOTE: I also strongly caution against this due to the obvious security implications...but you know your situation/use better than we do.
This sounds like a terrible idea, security-wise. Don't do it.
If you're looking for a default login, as many sites show with a textboxes having "username" and "password", then they are attributes of the input tag.
If you want to automate a login for a demo purposes, as many FLOSS projects do, you could prefill with a combo of demo/demo (or similar), also as attributes of the input tag.

Resources