Resources

My Agape try

Your Agape try


Support Forum

You must be logged in to post Login Register

Search 
Search Forums:


 




Get current users groups

UserPost

9:58 am
March 3, 2009


Josti

Member

posts 4

1

Hello,

First, let me thank you for that GREAT plugin!

I restricted the access to a whole category to a certain RS Group ("members"). Now I have a hardcoded Link to that category which should only be visible when the current user is a member.

Now:

<li><a href="/forum/role-scoper/page-1/<?php echo(get_category_link(1)); ?>">Intern</a></li>

I want to have a check ala current_user_can("read_post", $category_id); to toggle visibility of the link.


Is this possible?

1:12 pm
March 3, 2009


Kevin

Admin

posts 2503

2

I've not yet written a wrapper function to make it quite that easy.

For now, your simplest solutions is probably:

$readable_cat_ids = get_terms( 'category', 'fields=ids&skip_teaser=1' );
if ( in_array( $category_id, $readable_cat_ids ) ) {
  // display your link 
}

Using that argument string, your get_terms request will just pull from the cache that was already generated for post category filtering, so there won't be any performance hit.

You can also check for group membership directly:

global $current_user;
if ( isset( $current_user->groups[$group_id] ) ) {
  // do stuff
}

4:48 am
March 4, 2009


Josti

Member

posts 4

3

Thanks for your solution, working perfectly!

I really would like to see more templating features like those added to Role Scoper!


About the Agapetry forum

Currently Online:

13 Guests

Maximum Online: 150

Forums:

Groups: 2

Forums: 7

Topics: 1246

Posts: 5654

Members:

There are 1257 members

There are 1 guests


Kevin has made 2503 posts

Top Posters:

metal450 - 178

Ragnar - 108

YikYak - 70

whiteorb - 49

Daisy - 35

Administrator: Kevin | Moderators: Kevin