This topic is locked
[SOLVED]

 help with code - automated group permissions

10/5/2010 8:47:19 PM
PHPRunner General questions
K
karmacomposer author

Tyring to add an after successful registration event, but having problems due to not knowing the code to do it.
I found out that I need to add an event on the UserValidation table, in the Register page and after successful registration.
They give the function:
function AfterSuccessfulRegistration($userdata)

{
Now, in the admin area, I have created four groups: Recruiters, Employers, Candidates and CandidatesVisa
On the Register page is a drop down choice with Recruiters, Employers, Candidates and CandidatesVisa as the possible choices.
Four tables exist as well called Recruiters, Employers, Candidates and CandidatesVisa.
What I need direction on is the following:
I want to create a function that gives the person registering permission to the group they are registering for so they can only enter data for that group and only see and edit their own records in the tables meant only for them.
I appreciate the help. This is time critical right now and I really don't know the commands.
I am pretty sure this is wrong, but I am flying blind here:
function AfterSuccessfulRegistration($data["Sign Up As"]);

global $conn;

// if $data["Sign Up As"]="Rec" then

$strSQLInsert = "insert into admin_rights (TableName) values (Recruiter)";

db_exec($strSQLInsert,$conn);

//endif
I remarked the if/endif because I am not sure you can use that in sql.
My thought is, if "Sign Up As"="Recruiter" then change tablename (not sure if that is the admin field for group rights) to "Recruiter"
Am I totally wrong in my thinking? What is the proper code for doing this?

K
karmacomposer author 10/5/2010

Would I use this session variable?
$_SESSION["AccessLevel"]

ACCESS_LEVEL_GUEST - guest user

ACCESS_LEVEL_USER - regular user

ACCESS_LEVEL_ADMINGROUP - user belongs to the admin group

ACCESS_LEVEL_ADMIN - obsolete
Where AccessLevel is the groups I created?
If so, how would I apply this to the after successful registration event?
Mike

Sergey Kornilov admin 10/6/2010

You cannot have four login tables. You can only have one.
The best approach is to have a field GroupID (or 'Sign Up As') which will take values of 'Recruiter', 'Employer' etc.
Then on Registration add GroupID field and make it a radio-button control with the same four values. Nothing to code manually.

K
karmacomposer author 10/6/2010



You cannot have four login tables. You can only have one.
The best approach is to have a field GroupID (or 'Sign Up As') which will take values of 'Recruiter', 'Employer' etc.
Then on Registration add GroupID field and make it a radio-button control with the same four values. Nothing to code manually.


Not sure I follow. Where would I put the radio button control?
Mike

Sergey Kornilov admin 10/6/2010

Per my recommendation you need to add it on Registration page.

K
karmacomposer author 10/6/2010



Per my recommendation you need to add it on Registration page.


Right now I have a drop down list with the four group choices. Is that not acceptable? Must it be radio buttons?
OK. I made them radio buttons. I'll see if that works.
Mike

Sergey Kornilov admin 10/6/2010

Mike,
it works exactly the same way, I just think radio-button looks better here aesthetically.

K
karmacomposer author 10/6/2010



Mike,
it works exactly the same way, I just think radio-button looks better here aesthetically.


ok. Thank you for your suggestions. The database is coming along nicely, although I have tons more to do.
Mike

K
karmacomposer author 10/6/2010



You cannot have four login tables. You can only have one.
The best approach is to have a field GroupID (or 'Sign Up As') which will take values of 'Recruiter', 'Employer' etc.
Then on Registration add GroupID field and make it a radio-button control with the same four values. Nothing to code manually.


I tried this. It still does not work. On the registration page, I have a field called GroupID with radio buttons (though I am changing them back to a drop down list).
Where I am not understanding (and not getting anywhere here) is the 1st part of your advice (The best approach is to have a field GroupID (or 'Sign Up As') which will take values of 'Recruiter', 'Employer' etc.)
You do not specify which table or where that goes. I added a GroupID to the UserValidation table, which also added it to all the other tables for security.
Perhaps the problem lies in the security tab and not the tables. Right now, in the ADVANCED tab, I have it set for the middle option (users can see and edit their own data only), The table I am using as the Current Table is UserValidation. The two fields are both set to UserID (GroupID is greyed out).
Is this where I should be looking to solve my problem?
Mike