Page 1 of 1

group members view only

PostPosted: Fri Apr 14, 2006 5:40 pm
Author: Skywalker
is it possible to create a function like admin view only but then for a user group

example of admin view only script

Code: Select all
# #-----[ OPEN ]------------------------------------------ #  includes/page_header.php  # #-----[ FIND ]------------------------------------------ #  $template->assign_block_vars('switch_user_logged_in', array());  # #-----[ AFTER, ADD ]------------------------------------------ #  // Admin Only View Mod       if ( $userdata['user_level'] == ADMIN )    {       $template->assign_block_vars('switch_admin_view_only', array());    } // Admin Only View Mod  # #-----[ OPEN ]------------------------------------------ ### templates/subSilver/**file_you_want_to_place_swicth_in**.tpl  # #-----[ FIND ]------------------------------------------ ## The code you want to remain hidden from everyone except Administrators  # #-----[ BEFORE **CODE**, ADD ]------------------------------------------ #  <BEGIN>  <END># #-----[ AFTER **CODE**, ADD ]------------------------------------------ #  


but then for example a group called beta testers.
the function would be that only beta testers can acces beta mod pages on my board and al the other members iff the visit that page get an empty page

PostPosted: Fri Apr 14, 2006 6:47 pm
Author: Adrian Rea
This feature is already available as I see it. If you are making a block for a new page, you will find check boxes at the bottom for the usergroups you have. tick the apropriate box and only they will see the block. You may need a second block open to all stating that t'this is a Beta testers page, only they can see the content on this page' otherwise you see a quite bare page.

A

PostPosted: Sat Apr 15, 2006 5:00 am
Author: Skywalker
"Adrian Rea";p="1677" wrote:This feature is already available as I see it. If you are making a block for a new page, you will find check boxes at the bottom for the usergroups you have. tick the apropriate box and only they will see the block. You may need a second block open to all stating that t'this is a Beta testers page, only they can see the content on this page' otherwise you see a quite bare page.

A


no i mean for pages of new mods i'm willing to install and need to be tested.

the function you recall i can't use

Re: group members view only

PostPosted: Wed May 03, 2006 6:11 am
Author: found it
I have a mod that allows only one group to view an image or a link is that what you are after...

:mrgreen:

Re: group members view only

PostPosted: Wed May 03, 2006 9:45 am
Author: Skywalker
"found it";p="4290" wrote:I have a mod that allows only one group to view an image or a link is that what you are after...

:mrgreen:


i mean i script like the one i posted but then for usergroups.
but maybe i can expand your script to work like i need to you may always post it

Re: group members view only

PostPosted: Wed May 03, 2006 9:57 am
Author: found it
this is really rough but does work.....

if you make any progress with this i would be gratefull for any updates


First, get the group id number.
You can get this by clicking on usergroups and selecting the group.
The number will be at the end of the URL like groupcp.php?g=19
So the group id number would be 19

Second, open includes/page_header.php
Find:

Code: Select all
$template->assign_block_vars('switch_user_logged_in', array());



Now add after that]// SQL to get the user's group$sql = "SELECT * FROM " . USER_GROUP_TABLE . " WHERE user_id = " . $userdata['user_id'] . " AND group_id = 'GROUP_NUMBER_HERE' AND user_pending != " . TRUE;  // Did the SQL process successfully?if ( ! ($group_result = $db->sql_query($sql) ) ){    message_die(GENERAL_ERROR, "Could not obtain usergroup", '', __LINE__, __FILE__, $sql);}  // Is the user in the group?if ( $group = $db->sql_fetchrow($group_result) ){    $template->assign_block_vars('switch_user_in_group', array() );}  //No, they aren't in that groupelse{    $template->assign_block_vars('switch_user_not_in_group', array() );} [/code]

(Replace GROUP_NUMBER_HERE with the group id number.)
Now, in any template file you can use


in your template files

Code: Select all
 <BEGIN>image/link whatever here for the special group<END>


or

Code: Select all
<BEGIN>image/link whatever for people not in group<END>


I hope that is of some use

:mrgreen:

Re: group members view only

PostPosted: Wed May 03, 2006 10:47 am
Author: Skywalker
this is exactly what i'm looking for.

Re: group members view only

PostPosted: Wed May 03, 2006 10:48 am
Author: found it
glad to help...

:mrgreen: