Custom Registation Template choose User Level Security

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
cdmak
User
Posts: 27

Custom Registation Template choose User Level Security

Post by cdmak »

Hello,

I built a custom registration template and would like to include two user level security choices there, it would just be two radio buttons where the user can pick from the two choices. Can this be done? I went through the tutorial but did not see how it could be done. Thank You.

<p>
<label>
<input type="radio" name="access_level" value="1" id="user_level_security_0" />
Option One</label>
<br />
<label>
<input type="radio" name="access_level" value="2" id="user_level_security_1" />
Option Two</label>
<br />
</p>

I tried to pass the value to the Registration Page > Client Script
Still looking through the help.

$access_level = stripcslashes($_POST['access_level']);
$rsnew["access_level"] = "$access_level";


kirondedshem
User
Posts: 642

Post by kirondedshem »

There is abetter way to handle that:

  1. create acustom field in the user_accounts table maybe "select_user_group"(leave sql expression empty).
  2. SEt edit tage to drop down or checkbox, then either add userlevels in user values OR make it a lookup to a view having the user levels you want user to pick from. Make it required
  3. Go to security->advanced security-> user login options->user registration page and in the fileds ensure you also tick the cutsom filed to apperar on registration page
    NOW you should be able to see a drop down to choose specific user levels on the registration page
    NOTE: A user will be inserted without a user level so you must set the user level passsed as his user level
  4. go to server events tab->other->registratio page->User_Registered and put your code to update a new user's user level based on what was selected in our custom field, use $rs array to access the new record

// User Registered event
function User_Registered(&$rs) {
//echo "User_Registered";
//NOW A USER HAS LAREDAY BEEN INSERTED IN DB

    //SO UPDATe his user level

   ew_Execute(" update user_table set user_level_id = '".$rs["select_user_group"]."' where id = '".$rs["id"]."' ");
var_dump($rs);

}


cdmak
User
Posts: 27

Post by cdmak »

Thank you kirondedshem that is absolute awesome, I was thinking of a go between temp field like this but didn't know if the field would be inserting into access_level field or if it would be there if it was not checked off in the registration security.

Very awesome, thank you again for your help.


Post Reply