0

I am developing a website with Domain Access. Each domain has the same structure but different content. I would like to show online users. When I activate who's online block from block list in admin, it will display all online users. But, I want to display the 'online user' for a particular domain.

I use Domain Strict module so users login only their assigned domain.

How can I show 'online user' of a particular domain using Who's online block.

1
  • Problem with Domain Access is that users log in to the system, not to particular site. So they are, in fact, logged in to all of your domains. If you are using some separation mechanism, please tell us how did you set it up. If you are not, please tell us you don't, too. Commented Oct 28, 2013 at 7:31

1 Answer 1

0

Domain Strict - Forces users to be members of domains in order to view content.

So they are still logged in to the whole system, that's what other modules can see.

The best you can do is to create your own module, or use PHP module to create a block with PHP filter. Use code similar to the one from this Drupal.org post:

// Count users with activity in the past defined period. $interval = time() - 900; // Perform database queries to gather online user lists. We use s.timestamp // rather than u.access because it is much faster is much faster.. $anonymous_count = sess_count($interval); $authenticated_users = db_query('SELECT u.uid, u.name FROM {users} u INNER JOIN {sessions} s ON u.uid = s.uid WHERE s.timestamp >= %d AND s.uid > 0 ORDER BY s.timestamp DESC', $interval); $authenticated_count = db_num_rows($authenticated_users); // Format the output with proper grammar. if ($anonymous_count == 1 && $authenticated_count == 1) { $output = t('There is currently %members and %visitors online.', array('%members' => format_plural($authenticated_count, '1 user', '@count users'), '%visitors' => format_plural($anonymous_count, '1 guest', '@count guests'))); } else { $output = t('There are currently %members and %visitors online.', array('%members' => format_plural($authenticated_count, '1 user', '@count users'), '%visitors' => format_plural($anonymous_count, '1 guest', '@count guests'))); } echo $output; 

Now you have 2 modifications to make:

  1. Get rid of the whole "anonymous" part, as you don't need it.
  2. Modify the $authenticated_users = db_query part to JOIN the table Domain Strict module uses, and only count users that have access to the current domain.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.