Resources

My Agape try

Your Agape try


Support Forum

Current User: Guest Login Register
Please consider registering

Search 
Search Forums:


 




Manually Adding to Group

UserPost

2:21 am
March 2, 2010


metal450

Member

posts 98

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 1326

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 98

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 1326

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 98

5

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



Reply to Topic: Manually Adding to Group

NOTE: New Posts are subject to administrator approval before being displayed

Guest Name (Required):

Guest EMail (Required):

Guest URL (required)

Math Required!
What is the sum of: 11 + 3        (Required)

Topic Reply:


 

About the Agapetry forum

Currently Online:

11 Guests

Maximum Online: 88

Forums:

Groups: 2

Forums: 7

Topics: 667

Posts: 3053

Members:

There are 601 members

There are 1 guests


Kevin has made 1326 posts

Top Posters:

metal450 - 98

YikYak - 58

Ragnar - 36

Daisy - 35

LorenW - 33

Administrator: Kevin | Moderators: Kevin