News:

SMF 2.1.6 has been released! Take it for a spin! Read more.

Main Menu

Specific Membergroups Viewing Certain Links

Started by Drunken Lemming, January 21, 2008, 07:30:54 PM

Previous topic - Next topic

Drunken Lemming

Hi, I'm Trying to make it possible so when you log in on the main website Depening on whether you are a Specific Membergroup or not You will see a link..or nothing at all

I have A Somewhat working code that i can only get to work for admins, guests, and logged (anybody logged in)

<?php
function Log_Admin($output_method = 'echo')
{
global
$scripturl, $txt, $user_info, $context;
if (
$context['user']['is_guest'])
echo
'';


The Above is for Guests See how the Echo doesnt display anything? well i dont want guests seeing the link

Now this Is Admins
<?php
function Log_Admin($output_method = 'echo')
{
global
$scripturl, $txt, $user_info, $context;
if (
$context['user']['is_admin'])
echo
'<a href="http://www.yourwebsite.com/link.php">Link</a>';


Now i want to make it SPECIFIC membergroups that the code works with. Not just the Generic admin logged in, or guest. does anybody know how i would do this? When i say Specific i mean The ones i have created for my forums such as Non Post based ones and a custom made ones

Drunken Lemming


Bambara

Hi there,

I have the same question also, I want to integrate the users members groups to my website, so certain users can not see some content, if anyone can help us on this will be much appreciated!

I saw in the Doc that we can check permissions and set permissions, but I am looking for a way to check the user group, not only if he is a guest, logged in or admin.

Thanks in advance for who ever will help with that.

Bambara

I figured a way to do that, you need to do the SQL query on the user table, each user has the GROUP_ID column, you can check after that if the GROUP_ID matches the one in the membergroup table....easy...but needs knowledge of SQL

Drunken Lemming

Quote from: Bambara on January 28, 2008, 04:21:22 PM
I figured a way to do that, you need to do the SQL query on the user table, each user has the GROUP_ID column, you can check after that if the GROUP_ID matches the one in the membergroup table....easy...but needs knowledge of SQL

So how can i Access the SQL Data? i have Cpanel with the Website

Drunken Lemming

**Bump** can anyone answer that question ?? ^^^

Drunken Lemming

bump.......the question 2 posts above???? Please I dont know how to Access that SQL stuff.

Kindred

#7

include('SSI.php');

$membergroupswithaccess = '1','2','4';
// (admin, global mods, regular members) see the membergroups configuration to get the ID of each group

foreach ($user_info['groups'] as $group)
{
if (in_array($group, $membergroupswithaccess))
  display_it=1;
}

if ($diplay_it) {
  echo 'show the page';
} else {
  echo ' Sorry. You can not see this page';
}


Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Drunken Lemming

alright But Will each specific membergroup have a number? like ones I make.

Kindred

#9
yes. each membergroup has a number. If you made new membergroups, you'll have to check the appropriate number for yourself.


Actually....   The original way I wrote that code could cause some issues..   I revised it.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Drunken Lemming

Hey I can't get this to work, I'm trying to Have it show up in a certain spot so if the allowed membergroups access the page They will See a Link to a feature that I have in the IF ALLOWED spot then display whatever, I put the IF NOT ALLOWED area just nothing so if a random person is on the page, they dont see the Feature, Seeing as how they dont have access because they are not that membergroup

But When I put the code down, Even having it on a different PHP file and doing a Function Type include, or just on the Page it will work on itself. The page turns out white, and the code Make the entire page just not show up.

any ideas?

Advertisement: