| User | Post |
|
1:05 pm January 26, 2010
| Jpadie
Member
| | | |
|
| posts 6 |
|
|
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 |
|
|
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 |
|
|
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 |
|
|
'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 |
|
|
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"
|
|