Resources

My Agape try

Your Agape try


Support Forum

Current User: Guest Login Register
Please consider registering

Search 
Search Forums:


 




is_restricted_rs used for checking category access?

UserPost

11:31 am
March 26, 2009


danf

Member

posts 24

1

Hi Kevin - congrats on the 1.0 release. 

Im trying to figure out in my theme whether a user has access to a particular category.  It looks like I can use is_restricted_rs for that, correct?


Can you provide some guidance on what the valid parameters are for src_name and scope_criteria fields?

i.e. would: if ( is_restricted_rs($cat_ID, 'category', 'read', 'term' ) ){…}  work?


As always  - thanks Kevin for a killer product.

9:58 am
March 27, 2009


Kevin

Admin

posts 1326

2

The template function is_restricted_rs() is only intended to provide information on the current content result set.

There are currently no simple API wrapper functions. You could achieve your goals via:

global $scoper;
$default_restrictions = $scoper->get_default_restrictions(TERM_SCOPE_RS);
$restrictions = $scoper->get_restrictions(TERM_SCOPE_RS, 'category');

The main complication is that if you have any default category restrictions set, get_restrictions() will return category-specific restrictions and unrestrictions.

I haven't made the time to document those functions much. Want to help? If you put this in your wp-config.php:

define('RS_DEBUG', 'true');

… then you can use dump( $restrictions ) to conveniently view the contents of the get_restrictions() output.

11:01 pm
May 8, 2009


elricho

New Member

posts 1

3

Hi Danf, Hi Kevin,

I know its a few months late … but just in case this helps anyone else.

$str = implode(",", array_keys($current_user->get_groups_for_user($user_id))); $res = call_user_func( array(&$wpdb, 'get_results'), 'select distinct t.name, g.group_name from wp_groups_rs g, wp_terms t, wp_user2role2object_rs uro where uro.group_id in ('.$str.') and uro.obj_or_term_id = t.term_id and uro.group_id = id'); That will get you the category names with the group_id … Thanks for the software Kevin - Its excellent.



Reply to Topic: is_restricted_rs used for checking category access?

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: 6 + 11        (Required)

Topic Reply:


 

About the Agapetry forum

Currently Online:

12 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