WordPress.org

Ready to get started?Download WordPress

Forums

Front-end Editor
[resolved] How to allow a subscriber to edit only their contributed post? (13 posts)

  1. nm
    Member
    Posted 3 years ago #

    I'm trying to see if I can allow members of a MU network to edit posts they've contributed to sites. Their role is always subscriber.

    If these users visit their post they can see it is available for them to edit? and of course they wouldn't be allowed to edit any other posts that they havent authored.

    http://wordpress.org/extend/plugins/front-end-editor/

  2. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    If the 'subscriber' role has the 'edit_posts' capability on your site, yes, FEE should work as expected.

    Otherwise, try changing their role to 'contributor'.

  3. nm
    Member
    Posted 3 years ago #

    I was trying to avoid adding or changing of roles of registered members of a multisite network. Members can post to different sites on the network already and their authorship is saved just fine with no role. Otherwise I imagine that would be a pain to manage roles. Also users only post from the fronted so no need for access to the wp-admin posting screen if assigned contributor for example. And I'd hate to have to manage the list of users on each site if I had to assign roles for every poster. Unless there is a reason that users that author a post need to be assigned a role at all...i'm sure there is...but i rather like the clean user lists in the admin.

    Any way to know if the registered/loggedin current_userid matches the author id of the post?

  4. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    You can use the 'front_end_editor_allow_post' filter:

    http://github.com/scribu/wp-front-end-editor/wiki/Actions-and-filters

    function fee_only_own_posts( $allow, $data ) {
        return get_current_user_id() == get_post_field( 'post_author', $data['post_id'] ) );
    }
    add_filter( 'front_end_editor_allow_post', 'fee_only_own_posts', 10, 2 );
  5. nm
    Member
    Posted 3 years ago #

    nice one! tx scribu!

  6. nm
    Member
    Posted 3 years ago #

    Update.

    I thought it was working but it seems to only be working for the superadmin user. As superadmin I can edit my authored post but not others...but as a regular user who's authored a post, I can't edit my post.

  7. nm
    Member
    Posted 3 years ago #

    looks like it was still tied to the role capability...the author needs to have the edit_posts capability. I guess i'll have to assign roles...

    I'll look to see if there's a way to bypass this...especially since a registered user's id is saved as the author id so that should be enough to give them access to edit.

  8. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    Or you could just add the 'edit_posts' capability to the 'subscriber' role.

    This is easily done with a plugin, such as Capability Manager.

  9. nm
    Member
    Posted 3 years ago #

    I tried adding the edit_posts capability to subscriber but it wasn't enough I ended up having to set publish_posts as well...or else the editor wouldn't load -- this was members plugin.

    I'll try now capability manager

  10. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    There's isn't any point in switching to Capability Manager since they both manipulate the same information.

    I think the capability you're looking for is actually 'edit_published_posts'.

  11. nm
    Member
    Posted 3 years ago #

    hehe. No that alone with edit_posts didn't work, I actually had to have pretty much the same caps as Editor, including publish_posts/page and edit_publish_posts/pages. For the frontend editor to fully load. and by that time I've given subscribers acess to wp-admin dashboard so...I'll need then another plugin to block that. :)

  12. nm
    Member
    Posted 3 years ago #

    got it. couldn't get it to work with subscriber because wp will not recognize them enough to be the author(technically) in the post edit page & for whatever reason wouldn't take with the increased capabilities. so had to make it contributor so wp would make nice and then give contributor the edit_publish_posts/edit_post cap. thanks for your help... btw I'm no fan of roles and caps. :)

    ... I do hope to see more improvements on the title tag stuff...because when I turn on the Title field it screws up all my post titles...I looked at the title_attribute thing but I don't know how much editing I want to do to all the different files but especially plugins and widgets that I can't edit the title too.

  13. scribu
    Member
    Plugin Author

    Posted 3 years ago #

    I'm afraid there isn't anything I can do about the titles.

    The filter is simply applied (wrongly) in too many places.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic