Resources

My Agape try

Your Agape try


Support Forum

You must be logged in to post Login Register

Search 
Search Forums:


 




Hidden Editing Elements

UserPost

9:52 pm
July 5, 2009


starakaj

Member

posts 3

1

Hi Kevin,

Thanks for a great plugin, or for what I'm sure will be a great plugin once I get it working the way I want to.

I want to have a section of my posts that is only visible to users with editing privileges.  I'm almost sure that this is both possible and easy to do with hidden editing elements, so the problem must be me.  I've made sure that my div with the content I want hidden has the id "authordiv" (which is one of the html ids under "post edit form html ids" by default), but any user, no matter how small their role, can still see the content.  Any idea what I'm doing wrong?

-Thanks

10:42 pm
July 5, 2009


Kevin

Admin

posts 2503

2

Role Scoper's Hidden Editing Elements feature pertains to the Post / Page Edit Form. It does not affect reading access in any way. To restrict read access to a custom-defined portion of a post, try the Hide Post plugin.

7:57 am
July 7, 2009


starakaj

Member

posts 3

3

Oh, I see.  the way I was trying to do things didn't make any sense.

But even with the hide post plugin I still can't get things working quite the way I want.  What I'd really like to do is display a link directly to the 'add post' part of the backend when the user is viewing a category to which he can add posts.  I tried:

if (current_user_can('publish_posts')) { // display the link}

but this displays the link for all categories if the user can add posts to any category.  So I tried:

if (current_user_can('publish_posts', $_GET["cat"])) { //display the link}

This, of course, doesn't work either, and seems to have the opposite effect: the user only sees the link for any category if he can add posts to all categories. 

It's very puzzling, because I'm calling edit_post_link in the loop, which seems to be working correctly (it only displays if the user can edit posts in the category).  I checked the code and as far as I can tell edit_post_link just calls current_user_can('manage_categories') to determine whether to display the link.

Anyway, all the help is appreciated muchly.

10:56 am
July 7, 2009


Kevin

Admin

posts 2503

4

starakaj said:

What I'd really like to do is display a link directly to the 'add post' part of the backend when the user is viewing a category to which he can add posts.


Following some minor changes in the updated Role Scoper Development Snapshot, the following function call can now be inserted into your front-end template code to return an array of category IDs which the user can post to:

global $scoper;
$term_ids = $scoper->get_terms( 'category', true, COL_ID_RS, 0, array( 'access_name' => 'admin' ) );

6:48 pm
July 7, 2009


starakaj

Member

posts 3

5

Thank you so much, that works perfectly.  Would you mind terribly explaining what that code is doing?

10:41 am
July 9, 2009


Kevin

Admin

posts 2503

6

starakaj said:

Thank you so much, that works perfectly.  Would you mind terribly explaining what that code is doing?


The code snippet is just calling Role Scoper's internal get_terms function. That function is used by Role Scoper primarily to filter the WordPress get_terms / get_categories / wp_list_categories function. It considers any Restrictions/Roles you've assigned and normally applies capability requirements based on the URL it's called from. My modification was to support an access_name argument so you are able to get the list of posting/editing categories in call from the front end.


About the Agapetry forum

Currently Online:

14 Guests

Maximum Online: 150

Forums:

Groups: 2

Forums: 7

Topics: 1247

Posts: 5656

Members:

There are 1259 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