Author Topic: if logged in: show this and that in frontend  (Read 4192 times)

snark

  • Guest
if logged in: show this and that in frontend
« on: June 18, 2010, 07:36:20 PM »
is there a way to hide certain things on the fronend and only show them when a user is logged in

eason:

I want to hide the downloadcounts from the download module but make em visible to the logged in user(s)

Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: if logged in: show this and that in frontend
« Reply #1 on: June 19, 2010, 12:10:07 AM »
Try this:

Code: [Select]

<?php
// check if user is logged in
  
if ($wb->is_authenticated()){
    
$groups $wb->get_groups_name();
    
//check if user is part of _Usergroupname_
    
if(in_array(&#39;_Usergroupname_&#39;, $groups)) {
        
        
echo "I&#39;m logged in, and I am member of group _Usergroupname_";
       
    }else{
        
        echo 
""//nothing
        
    
}
  }

should work.

Let me know.

Regards,
Stefek
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

snark

  • Guest
Re: if logged in: show this and that in frontend
« Reply #2 on: June 19, 2010, 09:19:10 AM »
yeah, but now I have to put it into the loop of the downloadmodule ...

I guess it has to be a droplet because I cannot put php code into the loop


Offline Stefek

  • Posts: 6177
  • Gender: Male
  • ("ړ)
Re: if logged in: show this and that in frontend
« Reply #3 on: June 19, 2010, 12:39:59 PM »
Have you considered to hide this part with CSS?

Regards,
Stefek
"Gemeinsam schafft man mehr."

gemeinsam
1. mehreren Personen oder Dingen in gleicher Weise gehörend, eigen
2. in Gemeinschaft [unternommen, zu bewältigen]; zusammen, miteinander
#Duden

snark

  • Guest
Re: if logged in: show this and that in frontend
« Reply #4 on: June 21, 2010, 08:24:02 AM »
solved it ...


I made two droplets one called "downloadcountstart"   the other one called "downloadcountend"

Code: [Select]
global $database, $wb;
if ($wb->is_authenticated() ) {                   
return 'downloads: ';
}
else {
return '<!--';
}

Code: [Select]
global $database, $wb;
if ($wb->is_authenticated() ) {                   
return '|';
}
else {
return '-->';
}



after that I made a change to the loop in the downloadmodule settings-tab

I changed "downloads: [DL] |" to: "[[downloadcountstart]] [DL] [[downloadcountend]]"


this way it only is shown to a user that is logged in, for all regular visitors it is not shown


 

postern-length