| User | Post |
|
7:27 pm October 31, 2010
| topher1kenobe
Member
| | | |
|
| posts 5 |
|
|
I'm doing some pretty heavy editing of my theme, incorporating a fair bit of non-wordpress code. I want to be able to see what groups the current user is in. Is there something like user_groups() that returns an array or something?
|
|
|
2:17 pm November 1, 2010
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
Yes, you can get an array of group_ids for the currently logged user as follows:
global $current_user;
$group_ids = $current_user->groups;
|
|
|
4:07 pm November 1, 2010
| topher1kenobe
Member
| | | |
|
| posts 5 |
|
|
Is there any way to get the names of groups, so that I can do things like
if(in_array($user, groups)) {
code stuff
}
|
|
|
9:16 pm November 1, 2010
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
topher1kenobe said:
Is there any way to get the names of groups…
}
$group = ScoperAdminLib::get_group( $group_id );
$group_name = $group->display_name;
$group = ScoperAdminLib::get_group_by_name( $group_name );
$group_id = $group->ID;
$groups = ScoperAdminLib::get_all_groups();
$users = ScoperAdminLib::get_group_members( $group_id );
|
|
|
9:43 am November 2, 2010
| topher1kenobe
Member
| | | |
|
| posts 5 |
|
|
Perfect. Are there docs for this anyplace?
|
|
|
10:52 am January 10, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
topher1kenobe said:
Perfect. Are there docs for this anyplace?
It's on the todo list.
|
|
|
|
|
topher1kenobe said:
Perfect. Are there docs for this anyplace?
hi … I have tried your code. I put in author.php user group does not appear. whether there is something wrong with my code……….?
I use WP 3.0.4 and the theme twentyten
<?php $group = ScoperAdminLib::get_group( $group_id ); $group_name = $group->display_name; $group = ScoperAdminLib::get_group_by_name( $group_name ); $group_id = $group->ID; $groups = ScoperAdminLib::get_all_groups(); $users = ScoperAdminLib::get_group_members( $group_id ); ?>
|
|
|
|
|
Kevin said:
topher1kenobe said:
Is there any way to get the names of groups…
}
$group = ScoperAdminLib::get_group( $group_id );
$group_name = $group->display_name;
$group = ScoperAdminLib::get_group_by_name( $group_name );
$group_id = $group->ID;
$groups = ScoperAdminLib::get_all_groups();
$users = ScoperAdminLib::get_group_members( $group_id );
hi … I have tried your code. I put in author.php user group does not appear. whether there is something wrong with my code……….?
I use WP 3.0.4 and the theme twentyten
<?php $group = ScoperAdminLib::get_group( $group_id ); $group_name = $group->display_name; $group = ScoperAdminLib::get_group_by_name( $group_name ); $group_id = $group->ID; $groups = ScoperAdminLib::get_all_groups(); $users = ScoperAdminLib::get_group_members( $group_id ); ?>
|
|
|
8:51 am January 31, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
That code mixes two different group retrieval approaches. You need to supply either a valid group ID (if using ScoperAdminLib::get_group) or a valid group name (if using ScoperAdminLib::get_group_by_name).
Also, if the "assume no front-end admin" option is enabled, you will need to include plugins/role-scoper/admin/admin_lib_rs.php manually.
|
|