| User | Post |
|
2:21 am March 2, 2010
| metal450
Member
| | | |
|
| posts 98 |
|
|
I just wanted to quickly verify I'm doing this the recommended/correct way. Is it safe to manually add a user to a group like so:
ScoperAdminLib::add_group_user($groupID, $userID);
And likewise, to check a user for group membership:
$currUser = wp_get_current_user(); if( isset($currUser->groups[$groupID] ) ) echo "IS MEMBER";
Thanks
|
|
|
9:43 am March 3, 2010
| Kevin
Admin
| | | |
|
| posts 1326 |
|
|
metal450 said:
I just wanted to quickly verify I'm doing this the recommended/correct way. Is it safe to manually add a user to a group like so:
ScoperAdminLib::add_group_user($groupID, $userID);
And likewise, to check a user for group membership:
$currUser = wp_get_current_user(); if( isset($currUser->groups[$groupID] ) ) echo "IS MEMBER";
Yes, that's what I recommend. The following function is also available if you don't know the group ID:
if ( $group = ScoperAdminLib::get_group_by_name( $name ) )
$groupID = $group->ID;
|
|
|
10:53 am March 3, 2010
| metal450
Member
| | | |
|
| posts 98 |
|
|
Great,
And one last thing: is there a way to check if a given user or group has access to a given post? I've been checking if the CURRENT user can access a post like this:
if( get_post($pID) ) //Exists, since this always returns posts, even inaccessible ones
if( query_posts('p='.$pID) ) //Accessible, since this will return nothing if the user can't access it
|
|
|
11:09 am March 3, 2010
| Kevin
Admin
| | | |
|
| posts 1326 |
|
|
Role Scoper also provides this function:
awp_user_can( 'read_post', $post_id, $user_id )
|
|
|
11:12 am March 3, 2010
| metal450
Member
| | | |
|
| posts 98 |
|
|
Aha!! Exactly what I was looking for - thanx
|
|