This topic is locked
[SOLVED]

 Can you set individual permissions for a group through t

10/5/2010 1:07:33 PM
PHPRunner General questions
K
karmacomposer author

As I have asked many times here now, I have three groups that need to fill out three forms.
I have wracked my brain over how to do this, but I think I came up with a solution, I just need someone to point me in the right direction on how to make it happen.
In the registration signup form, I have fields for username, password, email and account type (drop down box with: recruiter, employer and candidate)
I have three groups set up - recruiter, employer and candidate.
I have three tables made. You guessed it, recruiter, employer and candidate.
How would I make it so that when someone signs in (after they register successfully), the are automatically taken to the proper form utilizing the proper table for their category?
Mike

K
karmacomposer author 10/5/2010

OK. After reading more into this, 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.
Mike

K
karmacomposer author 10/5/2010

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?
Mike

A
ann 10/6/2010

Hi,
it's PHP code (not an SQL) in the After successful registration event, you can use if clause uncommented.

Also you are not supposed to change parameters of the function (just leave $userdata variable as it is).

Here is the code to try (MySQL):

global $conn;

if ($data["Sign Up As"]=="Rec"){

$strSQLInsert = "update admin_users set `Sign Up As`='Recruiter' where UserName='".$data["UserName"]."'";

db_exec($strSQLInsert,$conn);

}

where UserName is your actual user name.


If it doesn't help please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error. 'Demo Account' button can be found on the last screen in the program.

K
karmacomposer author 10/6/2010



Hi,
it's PHP code (not an SQL) in the After successful registration event, you can use if clause uncommented.

Also you are not supposed to change parameters of the function (just leave $userdata variable as it is).

Here is the code to try (MySQL):

global $conn;

if ($data["Sign Up As"]=="Rec"){

$strSQLInsert = "update admin_users set `Sign Up As`='Recruiter' where UserName='".$data["UserName"]."'";

db_exec($strSQLInsert,$conn);

}

where UserName is your actual user name.


If it doesn't help please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error. 'Demo Account' button can be found on the last screen in the program.


Ann,
So like this:
function AfterSuccessfulRegistration($userdata["Sign Up As"]);

global $conn;

if ($data["Sign Up As"]=="Rec"){

$strSQLInsert = "update admin_users set Sign Up As='Recruiter' where UserName='".$data["UserName"]."'";

db_exec($strSQLInsert,$conn);

}

where UserName is your actual user name.
If you are asking me to put the actual user name, how can I do this? It has to be tied to the username variable in the registration form, right?
Also, I just found out that I was clipping off the text in 'Sign Up As' by setting the varchar to 3. I set it to 20 so that the four variables remained as they are. Do I even need the if statement as a result?
Again, I am trying to change the user's group permission here. Is this what this code block is doing?
Mike

A
ann 10/6/2010

Mike,
here is the correct line:

function AfterSuccessfulRegistration($userdata);



actually you can't change this line in the wizard.

K
karmacomposer author 10/6/2010



Mike,
here is the correct line:

function AfterSuccessfulRegistration($userdata);



actually you can't change this line in the wizard.


Okay. So is the following correct:
global $conn;

if ($data["Sign Up As"]=="Recruiter"){

$strSQLInsert = "update admin_users set Sign Up As='Recruiter' where UserName='".$data["UserName"]."'";

db_exec($strSQLInsert,$conn);

}
if ($data["Sign Up As"]=="Employer"){

$strSQLInsert = "update admin_users set Sign Up As='Employer' where UserName='".$data["UserName"]."'";

db_exec($strSQLInsert,$conn);

}
if ($data["Sign Up As"]=="Candidate"){

$strSQLInsert = "update admin_users set Sign Up As='Candidate' where UserName='".$data["UserName"]."'";

db_exec($strSQLInsert,$conn);

}
if ($data["Sign Up As"]=="CandidateVisaOnly"){

$strSQLInsert = "update admin_users set Sign Up As='CandidateVisaOnly' where UserName='".$data["UserName"]."'";

db_exec($strSQLInsert,$conn);

}
I must be doing something wrong because I get the following error after I try to register as a new user:
php error happened
Technical information

Error type 8

Error description Undefined variable: data

URL www.dealwithaces.com/acesDBtemp/register.php?

Error file /home/debra/public_html/dealwithaces.com/acesDBtemp/include/events.php

Error line 17

SQL query insert into UserValidation (UserName, Password, UserEmail, Sign Up As, UserActive) values ('melfelker', '52b772f1f1e63c09dcbf234950c743c3', 'mike@supersynths.com', 'Candidate', 0)
According to this error, I am attempting to put all of the field data into UserValidation, right? I just want to put the SECOND TO LAST FIELD, where it says 'Candidate'. Or am I wrong? Again, the whole point of this is to change the user's permission so they can only see and use the group they sign up for.
How would I do this?
Mike

A
ann 10/6/2010

Mike,
here is the code to try:

global $conn;

if ($userdata["Sign Up As"]){

$strSQLInsert = "update admin_users set `Sign Up As`='".$userdata["Sign Up As"]."' where UserName='".$userdata["UserName"]."'";

db_exec($strSQLInsert,$conn);

}



If it doesn't help please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error. 'Demo Account' button can be found on the last screen in the program.

K
karmacomposer author 10/6/2010

I uploaded to my demo account and sent a support ticket.
Still getting a php error:
Table 'debra_dwaces1.admin_users' doesn't exist
In fact, according to MyPHPAdmin, this table does NOT exist.
However, the following does exist:
dwa1_uggroups

dwa1_ugmembers

dwa1_ugrights
I think I need to put the group permissions in one of these (my guess is dwa1_uggroups)
Would I then alter the code to read like this:
global $conn;

if ($userdata["Sign Up As"]){

$strSQLInsert = "update dwa1_uggroups set Sign Up As='".$userdata["Sign Up As"]."' where UserName='".$userdata["UserName"]."'";

db_exec($strSQLInsert,$conn);

}
What do you think? If not uggroups, then which table?
Mike