Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: Show link to a specific group of users.  (Read 6574 times)

0 Members and 1 Guest are viewing this topic.

cherokee

  • Coppermine newbie
  • Offline Offline
  • Posts: 13
Show link to a specific group of users.
« on: February 18, 2014, 05:54:10 pm »

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

cherokee

  • Coppermine newbie
  • Offline Offline
  • Posts: 13
Re: Show link to a specific group of users.
« Reply #1 on: February 21, 2014, 01:43:11 pm »

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

 
Code: [Select]
// 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++;
        }
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Show link to a specific group of users.
« Reply #2 on: February 22, 2014, 01:04:01 pm »

$USER_DATA['groups'] contains an array of all user group IDs the current user belongs to, so something like
Code: [Select]
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
Code: [Select]
global $USER_DATA;before the if statement. When in doubt, add it as it won't break anything.
Logged

cherokee

  • Coppermine newbie
  • Offline Offline
  • Posts: 13
Re: Show link to a specific group of users.
« Reply #3 on: February 22, 2014, 03:39:54 pm »

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

cherokee

  • Coppermine newbie
  • Offline Offline
  • Posts: 13
Re: Show link to a specific group of users.
« Reply #4 on: February 22, 2014, 06:52:19 pm »

Sorry
I think it is
This is how I put it:
Code: [Select]
// 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
Logged

cherokee

  • Coppermine newbie
  • Offline Offline
  • Posts: 13
Re: Show link to a specific group of users.
« Reply #5 on: February 22, 2014, 07:01:56 pm »

Sorry
I think it is
This is how I put it:
Code: [Select]
// 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
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Show link to a specific group of users.
« Reply #6 on: February 22, 2014, 07:57:16 pm »

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

cherokee

  • Coppermine newbie
  • Offline Offline
  • Posts: 13
Re: Show link to a specific group of users.
« Reply #7 on: February 22, 2014, 08:19:31 pm »

Thank you very much
Logged
Pages: [1]   Go Up
 

Page created in 0.02 seconds with 20 queries.