WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: snark on June 18, 2010, 07:36:20 PM

Title: if logged in: show this and that in frontend
Post by: snark 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)
Title: Re: if logged in: show this and that in frontend
Post by: Stefek 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
Title: Re: if logged in: show this and that in frontend
Post by: snark 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

Title: Re: if logged in: show this and that in frontend
Post by: Stefek on June 19, 2010, 12:39:59 PM
Have you considered to hide this part with CSS?

Regards,
Stefek
Title: Re: if logged in: show this and that in frontend
Post by: snark 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