Show link to a specific group of users. Show link to a specific group of users.
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Show link to a specific group of users.

Started by cherokee, February 18, 2014, 05:54:10 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

cherokee

Hello.
I need to create a link is only visible to a particular user group. How I can do?
thanks
regards
Cherokee

cherokee

Hello.
I think this is how I can show and hide the link.
How could display only a certain group of users?
thanks
regards

// Button "Download"
        if ($CONFIG['plugin_enlargeit_buttondownload'] == '1' || ($CONFIG['plugin_enlargeit_buttondownload'] == 2 && USER_ID)) {
    $meta  .= <<< EOT
        enl_buttonurl[{$loopCounter}] = 'index.php?file=enlargeit/download&pid=';
        enl_buttontxt[{$loopCounter}] = '{$lang_plugin_enlargeit['download_this_file']}';
        enl_buttonoff[{$loopCounter}] = -208;

EOT;
            $loopCounter++;
        }

Αndré

$USER_DATA['groups'] contains an array of all user group IDs the current user belongs to, so something like
if (in_array(4, $USER_DATA['groups']))
should work if you want to display your button to the group with the ID "4". Depending where you want to add that code, you maybe need to add
global $USER_DATA;
before the if statement. When in doubt, add it as it won't break anything.

cherokee

Thanks André
I am unable to make it work, I'll keep trying.
regards

cherokee

Sorry
I think it is
This is how I put it:
// Button "Download"
global $USER_DATA; if (in_array(108, $USER_DATA['groups'])) {
        if ($CONFIG['plugin_enlargeit_buttondownload'] == '1' || ($CONFIG['plugin_enlargeit_buttondownload'] == 2 && USER_ID)) {
    $meta  .= <<< EOT
        enl_buttonurl[{$loopCounter}] = 'index.php?file=enlargeit/download&pid=';
        enl_buttontxt[{$loopCounter}] = '{$lang_plugin_enlargeit['download_this_file']}';
        enl_buttonoff[{$loopCounter}] = -208;

EOT;
            $loopCounter++;
        }
}

Just a question what if I close the post were several groups of users?
Thank you very much

cherokee

Quote from: cherokee on February 22, 2014, 06:52:19 PM
Sorry
I think it is
This is how I put it:
// Button "Download"
global $USER_DATA; if (in_array(4, $USER_DATA['groups'])) {
        if ($CONFIG['plugin_enlargeit_buttondownload'] == '1' || ($CONFIG['plugin_enlargeit_buttondownload'] == 2 && USER_ID)) {
    $meta  .= <<< EOT
        enl_buttonurl[{$loopCounter}] = 'index.php?file=enlargeit/download&pid=';
        enl_buttontxt[{$loopCounter}] = '{$lang_plugin_enlargeit['download_this_file']}';
        enl_buttonoff[{$loopCounter}] = -208;

EOT;
            $loopCounter++;
        }
}

Just a question what if I close the post were several groups of users?
Thank you very much

Αndré

Use something like
if (in_array(array(4, 5, 6), $USER_DATA['groups']))

cherokee