| User | Post |
|
4:08 pm July 19, 2011
| whiteorb
Member
| | whiteorb | |
|
| posts 49 |
|
|
I'm looking for a way to identify if a page has permissions set e.g. this page is only for the administrator group. This is so I can add an icon for a member's once they log in to identify which pages have been unlocked.
So something similar to this.
if (pages_role_is("administrator")); {
#Something goes here
}
Any help would be greatly appreciated.
|
|
|
8:44 am July 20, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
You can use the template function is_restricted_rs().
Or just check $post->post_status if you have hidden the page via private visibility.
|
|
|
9:47 am July 20, 2011
| whiteorb
Member
| | whiteorb | |
|
| posts 49 |
|
|
I hadn't realized that is_restricted_rs() was used for that purpose. Would you mind providing a small explanation. The documentation doesn't seem to say very much about it or it's output.
|
|
|
9:53 am July 20, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
is_restricted_rs( $post_id = 0 ) returns true if the Post Reader role is restricted (via Taxonomy Restriction or Post/Page Restriction) for the post. If no post_id is passed, global $post->ID is used.
|
|
|
9:58 am July 20, 2011
| whiteorb
Member
| | whiteorb | |
|
| posts 49 |
|
|
It returns true if the current reader is restricted or if it has restrictions placed on it at all? What I'm specifically looking to do is return a value if there are certain roles that were restricted.
|
|
|
10:15 am July 20, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
It doesn't pertain to the current user's access - just indicates whether the Reader role is restricted (i.e. requires a taxonomy-specific or object-specific role assignment).
The function is not designed to indicate a particular editing role restriction, but you can always manually query the table $wpdb->role_scope_rs (review with phpMyAdmin to determine column names). I can't provide any support on the details of that implementation right now.
|
|
|
1:27 pm July 20, 2011
| whiteorb
Member
| | whiteorb | |
|
| posts 49 |
|
|
hmmmm yeah I'm trying to apply a class to the menu that's hidden behing the member's area. Here is what I have so par. It seems to apply it to every single item. Do you think it's related to defining the anon group?
define( 'SCOPER_ANON_METAGROUP', true );
Here's where I am with the actual custom navigation code.
//Add class to menu item if user is logged in.
add_filter('nav_menu_css_class' , 'my_nav_special_class' , 10 , 2);
function my_nav_special_class($classes, $item){
if (is_restricted_rs( $post_id = 0 )); {
$classes[] = 'PARTNER_STAR';
}
return $classes;
}
|
|
|
8:10 am July 25, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
Try removing the semicolon on the is_restricted_rs() line.
|
|
|
10:48 am July 25, 2011
| whiteorb
Member
| | whiteorb | |
|
| posts 49 |
|
|
Yeah still unable to get this working properly.
|
|
|
11:14 am July 25, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
Also, the "$post_id = 0″ shouldn't be there in your function call. That's just part of the function definition, meaning you can pass a post ID optionally (otherwise it will assume $GLOBALS['post']->ID.
|
|
|
11:21 am July 25, 2011
| whiteorb
Member
| | whiteorb | |
|
| posts 49 |
|
|
Ah ok, that totally makes sense. I hadn't picked up on the intended reasoning for that last time.
However, now when you're logged in, every menu item will appear with the class. So it isn't differentiating between what is "restricted" and what isn't.
|
|
|
12:22 pm July 25, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
I'm not seeing any problem with is_restricted_rs() within loop.php. Not sure what exactly your custom navigation code but how about you just pass in the actual post ID on each iteration?
|
|
|
3:26 pm July 29, 2011
| whiteorb
Member
| | whiteorb | |
|
| posts 49 |
|
|
So I've simplified what I'm doing. However, I'm still not getting any love from is_restricted_rs(). In this case the user is logged in and looking at a post that is now visible.
within loop.php
<?php
if (is_restricted_rs()) {
echo '<img height="69″ width="70″ src="/wp-content/themes/openeye/images/partner-star.png">';
}
?>
If this worked properly he would be able to see a star next to the post.
Any thoughts on what I'm missing?
|
|
|
12:14 pm August 3, 2011
| whiteorb
Member
| | whiteorb | |
|
| posts 49 |
|
|
Anything on my last post?
|
|
|
9:52 pm August 4, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
Can you output an unconditional test string just to make sure the is_restricted() call is executing properly within the loop? Maybe substitute plain text for your star to rule out image retrieval problems?
Does the post have a Category Restriction or Post Restriction? What type of role assignment lets them see it?
In my trial, is_restricted() does return true for restricted posts which are displayed due to logged user's role(s).
|
|
|
10:39 am August 5, 2011
| whiteorb
Member
| | whiteorb | |
|
| posts 49 |
|
|
so I tried in my loop.
<?php
print is_restricted_rs()
?>
and
<?php
if (is_restricted_rs() == true) {
return 'test text';
};
?>
Still not working. Is there a setting somewhere that I need to enable?
|
|
|
10:02 pm August 5, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
The template functions are not disabled by any RS option. What about those questions on your configuration?
|
|
|
11:20 pm August 5, 2011
| whiteorb
Member
| | whiteorb | |
|
| posts 49 |
|
|
Perhaps I'm missing something. How do you suggest I output an unconditional. I thought I had done that above. Did I miss something?
|
|
|
11:20 pm August 5, 2011
| whiteorb
Member
| | whiteorb | |
|
| posts 49 |
|
|
|
2:44 pm August 10, 2011
| Kevin
Admin
| | | |
|
| posts 2503 |
|
|
whiteorb said:
Perhaps I'm missing something. How do you suggest I output an unconditional. I thought I had done that above. Did I miss something?
I meant just try the echo call without the is_restricted() check, just to make sure it's not a display issue.
|
|