Page 1 of 1

Checking Group Permissions

Posted: Mon Nov 17, 2008 12:37 pm
by forumace
While posting I want to check the group a user belongs to. If the User belongs to 'x' group then...

I want this to be added to posting.php so I can decide which registered members avoid the captcha in the following code:

if ($config['enable_post_confirm'] && !(of group 'x') && $solved_captcha === false && ($mode == 'post' || $mode == 'reply' || $mode == 'quote'))

Re: Checking Group Permissions

Posted: Mon Nov 17, 2008 12:47 pm
by Brf
That posting captcha is only for Guests, meaning it is only for users who are not logged in.
Therefore, they are not a member of any group other than Guests.

Re: Checking Group Permissions

Posted: Mon Nov 17, 2008 12:57 pm
by forumace
I know, but if you do this:

Code: Select all

if ($config['enable_post_confirm']  && $solved_captcha === false && ($mode == 'post' || $mode == 'reply' || $mode == 'quote'))
Then the CAPTCHA is for all. Basically I want registered members to still have to input the CAPTCHA, but not certain groups, any help will be appreciated, pretty please. Thanks.

Re: Checking Group Permissions

Posted: Mon Nov 17, 2008 1:05 pm
by Brf
You can user group_memberships() to find out what groups a user belongs to...

For instance, if you want to enable the captcha for groups 69 and 111 you would use:

Code: Select all

group_memberships(array(69,111), $user->data['user_id'], true)
Which would return true if the user belongs to either group.

Re: Checking Group Permissions

Posted: Mon Nov 17, 2008 1:21 pm
by forumace
Thanks much, but how will I call that from posting.php as group_memberships() is an undefined function there.

Re: Checking Group Permissions

Posted: Mon Nov 17, 2008 2:41 pm
by Brf
In posting.php, look for:

Code: Select all

		include($phpbb_root_path . 'includes/functions_user.' . $phpEx);
and remove it from there, and put it at the top after the other includes.

Re: Checking Group Permissions

Posted: Mon Nov 17, 2008 4:12 pm
by forumace
Thanks very much that worked very well for me. I could just kiss you, but that is not allowed so, just accept my thanks ;).