I'm looking to add some basic login functionality to a clients site. I've looked around for a sufficient plugin but haven't had any luck. I was hoping one of you might know of a plugin that can do what I'm looking for?
Here's the setup:
I have a "login page" that has a dropdown list with 6 options, and a name and email field. On submit, I just need the users/name and email to get mailed to a specified email address and then I need the user to get re-directed to a certain page based on what they choose in the dropdown.
So if they choose "company 1" from the dropdown I would need the user o get redirected to "company1.php"
I already own the [[LINK href="http://www.gravityforms.com/"]]Gravity Forms[[/LINK]] plugin and was thinking that I can use the built in query string functionality to pass a string to the "processing page" and the processing page would then route them to the correct page based on the query that was sent to it? I don't have much experience working with this so I was hoping you have experience with query strings or know of a plugin that can achieve what I need?
I really appreciate any direction on this.
Do you need people to be registered and check credentials on login? or is it just like a gateway to redirect people from one page to another depending on their choice?
No registration by the user is required. It will act as more of a gateway to just direct the user based on thier choice.
Ok, in that case you want to use a switch statement to check for the value of the variable that holds the chosen page. I'm going to assume you use POST and that the name of your select list is site. You need something like this:
$site = $_POST['site'];
case 'option 1':
header( 'Location: url/for/first/option.php' );
case 'option 2':
header( 'Location: url/for/second/option.php' );
header( 'Location: default/url/option.php' );
This has to be added before the headers are sent. Basically just putting it at the very beginning of your file would do it.
To send the mail you can use the built in [[LINK href="http://codex.wordpress.org/Function_Reference/wp_mail"]]wp_mail function[[/LINK]].
Something I forgot to mention. The call to wp_mail has to be done before the switch so it executes before the redirection.
Excellent. Thank you very much.
The plugin I am currently using allows me to pass a string to the "processing page". So when the user submits, the URL might be:
Can I use the code you posted above to read just the ?partner=company1 part of the string and use that to do the redirect?
In that case you are using GET. You see, there are two ways to pass data to another page (Actually more than two, but with forms there two common ways). One is post, and one is get. When you pass data through the URL, you are using GET method. PHP gets that data trough global variables, one of which is GET, another one of those is POST. Each one of them holds the data passed either through get or post respectively.
You would need to change the code above so it grabs data from $_GET and not $_POST.
$site = $_POST['site'];
$site = $_GET['site'];
oh, you also need to change the label of the variable you want to get:
$site = $_POST['partner'];