Resources

My Agape try

Your Agape try


Support Forum

You must be logged in to post Login Register

Search 
Search Forums:


 




Manually Adding to Group

UserPost

2:21 am
March 2, 2010


metal450

Member

posts 159

1

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 2402

2

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 159

3

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 2402

4

Role Scoper also provides this function:

awp_user_can( 'read_post', $post_id, $user_id )

11:12 am
March 3, 2010


metal450

Member

posts 159

5

Aha!! Exactly what I was looking for - thanx :D


About the Agapetry forum

Currently Online:

16 Guests

Maximum Online: 150

Forums:

Groups: 2

Forums: 7

Topics: 1186

Posts: 5409

Members:

There are 1176 members

There are 1 guests


Kevin has made 2402 posts

Top Posters:

metal450 - 159

Ragnar - 105

YikYak - 70

whiteorb - 44

Daisy - 35

Administrator: Kevin | Moderators: Kevin