Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 06:52:45 AM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155534 Posts in 21713 Topics by 7737 Members
Latest Member: chris85
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: if logged in: show this and that in frontend  (Read 998 times)
snark
Guest
« on: June 18, 2010, 06: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)
Logged
Stefek
WebsiteBaker Org e.V.

Offline Offline

Posts: 4884



« Reply #1 on: June 18, 2010, 11:10:07 PM »

Try this:

Code:

<?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('_Usergroupname_'$groups)) {
        
        echo 
"I'm logged in, and I am member of group _Usergroupname_";
       
    }else{
        
        echo 
""//nothing
        
    
}
  }

should work.

Let me know.

Regards,
Stefek
Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
snark
Guest
« Reply #2 on: June 19, 2010, 08: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

Logged
Stefek
WebsiteBaker Org e.V.

Offline Offline

Posts: 4884



« Reply #3 on: June 19, 2010, 11:39:59 AM »

Have you considered to hide this part with CSS?

Regards,
Stefek
Logged

"In a time of universal deceit, telling the truth becomes a revolutionary act."
- George Orwell, Nineteen eighty-four (1984)
snark
Guest
« Reply #4 on: June 21, 2010, 07:24:02 AM »

solved it ...


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

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

Code:
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

Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!