Resources

My Agape try

Your Agape try


Support Forum

You must be logged in to post Login Register

Search 
Search Forums:


 




Determine whether a user is a member of a RS Group

UserPost

1:05 pm
January 26, 2010


Jpadie

Member

posts 6

1

Hi

is there an easy way to determine whether a user is a member of a particular group?  i need to display different content on a page depending on which group a user is a member of.

I posted this question on 11 Jan as well, but my post appears to be deleted.  Apologies if it offended anyone.

Many thanks in advance

Justin

1:24 pm
January 26, 2010


Kevin

Admin

posts 2503

2

Jpadie said:

Hi

is there an easy way to determine whether a user is a member of a particular group?  i need to display different content on a page depending on which group a user is a member of.


$your_group = get_group_by_name( 'Your Group Name' );

global $current_user
if ( isset( $current_user->groups[ $your_group->ID ] ) ) {
  // display stuff
}

You can always hardcode the group ID(s) to eliminate one DB query from your script execution.

Jpadie said:

I posted this question on 11 Jan as well, but my post appears to be deleted.  Apologies if it offended anyone.


No offense here. I don't know how it got deleted; sorry about that.

2:58 am
February 18, 2010


mano

New Member

posts 1

3

Hello Kevin.


I'd like to do almost the same as Jpadie, but i've got this error:

Fatal error: Call to undefined function get_group_by_name()

3:59 am
February 18, 2010


Jpadie

Member

posts 6

4

'mano

you need to have the role_scoper plugin loaded.  the function lives in admin/admin_lib_rs.php  

I …think… you can bootstrap the necessary libraries by including admin/admin_rs.php


7:11 am
February 18, 2010


Kevin

Admin

posts 2503

5

That function will be available on the front end without any additional include calls, as long as you have this option disabled:

Roles > Options > Features tab > Front End > "Assume No Front-end Admin"


About the Agapetry forum

Currently Online:

17 Guests

Maximum Online: 150

Forums:

Groups: 2

Forums: 7

Topics: 1246

Posts: 5654

Members:

There are 1257 members

There are 1 guests


Kevin has made 2503 posts

Top Posters:

metal450 - 178

Ragnar - 108

YikYak - 70

whiteorb - 49

Daisy - 35

Administrator: Kevin | Moderators: Kevin