Hi,

In my profile template I'm using some code to display a message if a user IS NOT in any group (organic groups.) It checks the group node numbers and assigns each a name: "$student" for members of node 116 and "$public" for 117.

If a user is not a member of either group, I display a message:

print '<div class="groupnotification">You have not joined/ been accepted into any groups yet which makes you invisible on the site. Why not join a group?</div>';

The problem is, I'm using one sql query for both checks, and it's only paying attention to the first check, in this case "$public."
$is_active = db_result(db_query('SELECT is_active FROM og_uid WHERE uid = %d AND nid = %d', $user->uid, $public, $student));

Someone suggested I try adding "OR nid = %d" to the end of the query, which just caused it to ignore both checks.
$is_active = db_result(db_query('SELECT is_active FROM og_uid WHERE uid = %d AND nid = %d OR nid = %d', $user->uid, $public, $student));

How can I get it to acknowledge $public and $student?

Jon.

Comments

JonGirard-1’s picture

Forgot to include, my entire piece of code:

<?php
global $user;
$student = 116;
$public = 117;


$is_active = db_result(db_query('SELECT is_active FROM og_uid WHERE uid = %d AND nid = %d OR nid = %d', $user->uid, $public, $student));

if ($is_active==true){
print '';
}

else{
print '<div class="groupnotification">You have not joined/ been accepted into any groups yet which makes you invisible on the site. Why not join a group?</div>';
}
?>