PDA

View Full Version : Permissions based on non vB-setting?


Swedie
09-11-2008, 04:51 AM
Hey!

I have a problem where i need to assign permissions based on a value in a user field (a membership ID number).

The ID is at the moment checked towards an external database. If the ID is good I assign a Session value that gives access to certain forum IDs. For this I've written a PHP plugin, and a simple template based <if> statement).

But I would like to know if I can assign a user a certain Usergroup IF the given ID is good. That way I can create a usergroup that is allowed access to a forum based on the built in vBulletin permissions settings. This gives me a better overall control. Because right now the posts in a forum is still shown in Get new posts and other locations. Not until users click on the thread they are given the Message that they need to be authorized in order to view the thread / post in question.

I hope someone here knows what I mean and have a solution for me.

luki
09-11-2008, 04:28 PM
If I understood it:

First, create an usergroup in vBulletin that has the priviliges you want.
Then (I assume you're checking aganist valid id in your script), do your checking. If it's valid go like this:

// id of the group which user will be added to
$user_group_id = 5;

// id of the user that will be added to the group
$affected_user_id = 1;

$sql_query = "UPDATE user SET membergroupids = CONCAT(membergroupids, ',{$user_group_id}') WHERE userid = '{$affected_user_id}';";

Of course you have to adjust it to your needs.

You can check the member group id in CP, under Usergroups -> Usergroups manager.
Remember that you will need to connect to database which vBulletin forum is using, otherwise code will not work.

Swedie
09-12-2008, 06:19 AM
Thank you, that was what I was looking for. I've tuned the details for my needs.