Hiding My Groups block when there is nothing to show
Last updated on
30 April 2025
If a user is not a member of any groups, the My Groups block can still show.
To hide the block when the user is not a member of any groups, do the following:
1. Go to admin/build/block
2. Find the My Groups block. Click the Configure link.
3. Scroll down to "Page specific visibility settings." Check "Show if the following PHP code returns TRUE"
4. Paste this in the <textarea>:
global $user;
$uid= $user->uid;
$sql = "SELECT COUNT(*) FROM {og_uid} WHERE uid = %d";
$cnt = db_result(db_query($sql, $uid));
return $cnt > 0;
5. Click the "Save block" button.
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion