Jump to content
Sign in to follow this  
Alejandro

Logged in indicator for listing owner in listings (Joomla)

Recommended Posts

Alejandro

The question recently came up in another forum post. Using the same database query that Joomla uses in the administration of the site, you can add an indicator in listings to show if the listing owner is currently logged in to the site through a banner custom field.

 

In the PHP format setting for the field you can add the following code:

if ($entry['User']['user_id'] > 0)
{
    $db = JFactory::getDbo();
    $query = sprintf('
            SELECT s.userid
    	    FROM #__session AS s
    	    WHERE s.guest = 0 AND s.client_id = 0 AND s.userid = %d
    	    LIMIT 1', $entry['User']['user_id']);
    	    
    $userid = $db->setQuery($query)->loadResult();
   
    if ($userid) {
        return "User is logged in";
    }
}
return "User not logged in";

Share this post


Link to post
ededi

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Edited by ededi

Share this post


Link to post
Alejandro

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
ededi

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Edited by ededi

Share this post


Link to post
Alejandro

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
ededi

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Alejandro

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
ededi

This section is only visible with a valid subscription. If you have a valid subscription, please login.

Share this post


Link to post
Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Please refer to our Privacy Policy.