Topic: Checking for Guest and Default User in an Extension

So I'm trying to limit an extension so it can't be viewed by either a guest or the default user group (named "Visitor" on my forum). I'm not quite sure how to call that in the $forum_user variable.

if($forum_user['is_guest'] != true || $forum_user['Visitor'] != true) { blahblah }

returns

Notice: Undefined index: Visitor in header.php(133) : eval()'d code on line 28

How do I go about checking for both the guest and default user group (or specific group, in the case my "Visitor" group)?

2 (edited by YonasH 2008-12-29 23:14)

Re: Checking for Guest and Default User in an Extension

slickplaid wrote:

So I'm trying to limit an extension so it can't be viewed by either a guest or the default user group (named "Visitor" on my forum). I'm not quite sure how to call that in the $forum_user variable.

if($forum_user['is_guest'] != true || $forum_user['Visitor'] != true) { blahblah }

returns

Notice: Undefined index: Visitor in header.php(133) : eval()'d code on line 28

How do I go about checking for both the guest and default user group (or specific group, in the case my "Visitor" group)?

Hi
If you are doing this extension only for yourself, then use:

if(!$forum_user['is_guest'] || $forum_user['g_id'] != X) { blahblah }

where X is ID of your default group

if it is your forum Default group ( configured in http://www.yourpunbb.com/admin/groups.php ), then use

if(!$forum_user['is_guest'] || $forum_user['g_id'] != $forum_config['o_default_user_group']) { blahblah }

But if you want to share your extension, you should add new group permission option wink

YonasH's repository + Extensions Directory = PunBB Extensions Online Library (in progress....)

Away. I will be back soon.

Re: Checking for Guest and Default User in an Extension

Thank you for the quick response!

I just sat down to write up a quick extension (or rather to see if I could do it) and it's actually not that hard, but it'd be a bit easier if there was a list of all the variables available somewhere. If there is I must be blind cause I've looked for about an hour and haven't found any for 1.3.

Now you say that if I want to share it, I should add new group permission options. How would I go about doing that? Are you talking about adding the option into the Admin panel?

Thanks!

4 (edited by YonasH 2008-12-30 00:20)

Re: Checking for Guest and Default User in an Extension

slickplaid wrote:

Now you say that if I want to share it, I should add new group permission options. How would I go about doing that? Are you talking about adding the option into the Admin panel?

I don't know what type of extension are you writting, but different admins would probably like to turn it on/off for selectable users group. But it's not to hard neither. Admin files have plenty of hooks smile
It can be easier for you, when you'll use my extension as example: http://punbb.informer.com/forums/topic/ … ce-period/

1. create field in database (USE punBB name-calling style!)
2. add option to admin menu
3. add value checker if necessary
4. use new permission variable in your code
5. drink beer cool

YonasH's repository + Extensions Directory = PunBB Extensions Online Library (in progress....)

Away. I will be back soon.

Re: Checking for Guest and Default User in an Extension

I'll get right on that... Thanks for the help. big_smile