Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Help with recipe on jomsocial group member profiles

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?

asdfasdf
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

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: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

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.

asdfasdf
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

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: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Help with recipe on jomsocial group member profiles

will this work with jomsocial rather than cb?

asdfasdf
Beginner Modder
ranks
useravatar
Offline
7 Posts
Administrator has disabled public posting

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: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Help with recipe on jomsocial group member profiles

Stephen,

I am looking for something very similar except I use readybytes XIPT component for jomsocial (which basically is an advanced profile component for jomsocial).  It stores the profile types (that override jomsocial profile types) in the table: __xipt_users

with the fields being: userid,profiletype (numeric number like jomsocial profiletype), and template (not relevent to this query)

I'm looking to display specific modules only on pages for the user who is in a particular xipt profile type - this is what I tried so far, but did not see any results:

if  ($option == "com_community" and $view == "frontpage" ) {
  $userid = JRequest::getInt('userid',0);
  if ( $userid > 0 ) {
    $query = "select profiletype from #__xipt_users where userid = '$userid'";
    $db->setQuery( $query );
    $results = $db->loadResultArray();
    if ( is_array( $results ) ) {
      if ( in_array(7, $results) ) return 1293; // for profiletype 3, use module 1293
      // add more checks like the previous one, as appropriate
    }
  }
}

any help would be awesome!

amelcher
Beginner Modder
ranks
useravatar
Offline
13 Posts
Administrator has disabled public posting

Re: Help with recipe on jomsocial group member profiles

loadResultArray has been removed in Joomla 3. So I'd try the following:

if  ($option == "com_community" and $view == "frontpage" ) {
  $userid = JRequest::getInt('userid', 0);
  if ( $userid > 0 ) {
    $query = "select profiletype from #__xipt_users where userid = '$userid'";
    $db->setQuery( $query );
    $result = $db->loadResult();
    if ( $result == 7) return 1293; // for profiletype 7, use module 1293
  }
}


This relies on the user pages that you are detecting having a URL parameter called "userid" identifying the user that the page is about. I haven't checked that. But the rest of it is more likely to work, I think smile

Best regards,
Stephen

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

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Help with recipe on jomsocial group member profiles

Stephen,

Thanks for the help.  I added the code and it didn't work so after looking at the debug code at the bottom of the page I made one change and then it worked perfectly!
I swapped out :
$userid = JRequest::getInt('userid', 0);

with :
$userid = $jinput->get('my_user');
and so far it appears to be working smile

thanks again

Adam

amelcher
Beginner Modder
ranks
useravatar
Offline
13 Posts
Administrator has disabled public posting

Re: Help with recipe on jomsocial group member profiles

Perfect, well spotted. Advanced Debug function for the win!

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: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1684
Total Polls:
6
Total Posts:
5940
Posts this week:
1
User Info:
 
Total Users:
5162
Newest User:
david30x73
Members Online:
0
Guests Online:
91

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked