Is it possible to redirect user from login based on their Group/Level Name? I have tried all of the following with no luck:
$group = $_SESSION[mm_group]; // Groups or Company
$groups = $_SESSION[mm_groups]; // Groups or Company
$group_name = $_SESSION[mm_group_name]; // Groups or Company
$groupname = $_SESSION[mm_groupname]; // Groups or Company
I'd like to be able to organize our website with each user's access restricted to their own company folder. Group/Level Name would be the company's name. This way all users (employees) would be redirect to their own company folder and not have access to another company's folder.
I am not offering self registration, so no one will see the list of groups/levels.
Ryan
I believe there is a thread on redirecting based on sub/user group in the main PHP MM forum. You could also create a custom text field and do a redirect based on that. Typing in the folder name in the custom text field.
Or you could redirect on the username field, and have the username be the folder name.
This of course would not work if you wanted multiple accounts getting into one folder.
I believe there is a thread on redirecting based on sub/user group in the main PHP MM forum.
I was unable to find one. Could you please send me a link to this... thank you.
You could also create a custom text field and do a redirect based on that. Typing in the folder name in the custom text field.
Thought of that but, I'll be handing the admin. over to our sales staff and was looking for a clean and organized way to help them add users (customers) as needed without the redundancy of selecting the Group Name (which is the company name) and typing in the Company name into a custom text field.
Yes, it sounds simple enough, but the fact is, someone will forget to enter both.
Ryan
So you'll need multiple accounts to get into a specifc area?
So you'll need multiple accounts to get into a specific area?
Yes.
Would be something like this, but you could use a redirect HTML tag instead of showing a link based on group #:
http://www.i2-services.com/forum/showthread.php?tid=78
This option hands over the session's list number. And I have to add... I'm using the session data to fill in an order form. So now, if group #1 is "Acme Corp." the form's company field with be "1" not the actual company name.
Is there a way to convert the list number into the actual list name?
Sorry for the confusion!
Ryan
Look for the list/group # and set a new session variable based on it.
Look for the list/group # and set a new session variable based on it.
You've lost me.
Here is what I have currently as my index.php file inside the members folder:
<?php
require_once("../mm2/login_require.php");
visitor_login($groups="1",$username="0");
$user = $_SESSION[mm_name]; // Name
$username = $_SESSION[mm_username]; // Username
$password = $_SESSION[mm_password]; // Password
$lists = $_SESSION[mm_lists]; // Company
$email = $_SESSION[mm_email]; // Email
if ($user == "Ryan") {
header("Location: http://acme.onlineorders.com/cgi-bin/ord...6;_SESSION[mm_name]&user=$_SESSION[mm_username]&password=$_SESSION[mm_password]&company=$_SESSION[mm_lists]&telephone=$_SESSION[xxxx]&fax=$_SESSION[xxxx]&email=$_SESSION[mm_email]");
} else {
header("Location: http://www.onlineorders.com");
}
?>
The issue is that the lists data returns, as I mentioned, the list ID assigned to the user/account and not the list/group name itself.
I even tried:
$lists = $_SESSION[mm_lists.name]; // Company
and that didn't work.
Ryan
You're going to need to hard code in a variable for the group name, based on the session[lists].
IE:
if (preg_match("/,1,/i", "$_SESSION[mm_lists]")) {
$group_name = "What is group #1 name";
}
if (preg_match("/,2,/i", "$_SESSION[mm_lists]")) {
$group_name = "What is group #2 name";
}
Below is a cleaned up version of our "work-around" to this thread/topic.
Basically, were looking up and matching data which returns the actual Group Name, not the Group/List ID, which in turn, redirects the user/account to their own group (company) sub-domain.
<?php
require_once("../mm2/login_require.php");
visitor_login($groups="0",$username="0");
// Connects to MySQL data
mysql_connect('host','database_user','password');
mysql_select_db('database_name') or die( "Unable to select database");
// Constructs a joined query between "mm_lists" and "mm_groups"
$query = "SELECT mm_lists.name, mm_groups.username ".
"FROM mm_lists, mm_groups ".
"WHERE mm_lists.id = mm_groups.groups";
$result = mysql_query($query) or die(mysql_error());
$group_name = mysql_fetch_array($result);
$company = $group_name['name'];
$url = "http://www." . $company . ".onlineorders.com";
header("Location: $url");
?>
Ryan