Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.


asdfasdf
Beginner Modder
ranks
useravatar
User Info

Help with recipe on jomsocial group member profiles

I want a recipe for displaying a module on a person's jomsocial profile if they are the member of a jomsocial group.  In other words, if I go look at the profile of John Smith, and he is a member of the XYZ group, there will be a module on his profile (that will say he is a member of the XYZ group).

I tried working with the code I saw for displaying things for members of groups I found here:

$userid = $user->id;
$query = "select * from #__community_groups_members where memberid = '$userid';";
$db->setQuery( $query );
$row = $db->loadObject();
$group = $row->groupid;
$member = $row->memberid;
$approv = $row->approved;
if ( $member > 0 ) {
if ( $group = 3 && $approv = 1 ) return 427;
}

But I can't figure it out.  Is this possible?


Administrator has disabled public posting
metamodguy
useravatar
User Info

Re: Help with recipe on jomsocial group member profiles

Hi asdfasdf,

I haven't checked the exact query you are using, but for now I'll assume it's correct.

The only other problem I see in the recipe is in the 2nd "if" line... when you compare things for equality, you have to use "==" and not "=".

So the last 3 lines should read:
if ( $member > 0 ) {
  if ( $group == 3 && $approv == 1 ) return 427;
}

With the syntax you were using, I think module 427 would ALWAYS be returned for logged in users. Is that what was happening?

Cheers,
Stephen


Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory

Administrator has disabled public posting
asdfasdf
Beginner Modder
ranks
useravatar
User Info

Re: Help with recipe on jomsocial group member profiles

I made that change - but the issue now is still that it's displaying badges for whatever groups I am a member of, and not the groups the person's profile I'm looking at.  In other words, if I'm in group aaa and I look at someone else's profile it shows group aaa badge.  But they're not a member of it, I am.  I want to be able to display a badge showing what groups a person is a member of in their profile, but I'm stumped.


Administrator has disabled public posting
metamodguy
useravatar
User Info

Re: Help with recipe on jomsocial group member profiles

Ok, I think this is what you want. You need to be able to retrieve the user id of the page you are viewing, rather than doing the query based on the user id of the logged in user.

Therefore you can use this to get the user id of the user, as long as you are on a CB profile page:

$userid = JRequest::getInt('user',0);

So try this. I've fixed it up a bit so that it can detect multiple groups. The previous version only checked the 1st group the person was a member of.

Code:

if  ($option == "com_community" and $view == "profile" ) { 

  $userid = JRequest::getInt('userid',0);
  if ( $userid > 0 ) {
    $query = "select groupid from #__community_groups_members where memberid = '$userid' and approved = 1";
    $db->setQuery( $query );
    $results = $db->loadResultArray();
    if ( is_array( $results ) ) {
      if ( in_array(3, $results) ) return 47; // for group 3, use module 47
      // add more checks like the previous one, as appropriate
    }
  }
}



Edited By:  metamodguy
10-Oct-10 22:35:13

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory

Administrator has disabled public posting
asdfasdf
Beginner Modder
ranks
useravatar
User Info

Re: Help with recipe on jomsocial group member profiles

will this work with jomsocial rather than cb?


Administrator has disabled public posting
metamodguy
useravatar
User Info

Re: Help with recipe on jomsocial group member profiles

Oops, it looks like I seriously confused CB (com_profiler) with JomSocial (com_community). Let me do a new version for JomSocial...

Sorry! This is now edited in the post above, and tested, this time!

Stephen


Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory

Administrator has disabled public posting

Board Info

Board Stats:   Total Users: 3079  Total Topics: 1195  Total Polls: 7  Total Posts: 4448  Posts this week: 18
User Info:   Newest User :  raisaalam   Members Online: 0   Guests Online: 84
Online  There are no members online
Topic
New
Locked
Topic
New
Locked
Sticky
Active
New/Active
Sticky
Active
New/Active
New/Closed
New Sticky
Closed/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky Active Locked
Active/Sticky
Sticky/Locked
Sticky/Active/Locked