[wp-trac] [WordPress Trac] #44017: Add filter to display edit post link without 'edit_post' capability

WordPress Trac noreply at wordpress.org
Thu May 10 02:57:28 UTC 2018


#44017: Add filter to display edit post link without 'edit_post' capability
-----------------------------------------+------------------------------
 Reporter:  rafsuntaskin                 |       Owner:  (none)
     Type:  enhancement                  |      Status:  new
 Priority:  normal                       |   Milestone:  Awaiting Review
Component:  Posts, Post Types            |     Version:
 Severity:  major                        |  Resolution:
 Keywords:  has-patch reporter-feedback  |     Focuses:
-----------------------------------------+------------------------------

Comment (by rafsuntaskin):

 Hi @johnbillion ,

 Thank you for your response.

 Even if the URL is pointing another location you can't show the link using
 `get_edit_post_link` filter unless the user has 'edit_post' capability.
 Because the function bails out before that filter is even fired.

 As I have said we can allow users to Edit or Create posts from Front-end
 using various Form plugins or implementing custom forms. In that case you
 don't want users to have `edit_posts` capability as it's too much.

 Suppose, we are creating a simple directory site where we allow users to
 post a Directory info using A custom form template which are saved as
 post. We can also allow users to edit the info using the Same form
 template.
 So, even if the user is set as `post_author` he won't see the `Edit` link
 by default. Because the `edit_post_link` function checks for `edit_post`
 capability and bails out immediately before running the
 `get_edit_post_link` filter.

 Here is a screenshot :
 [[Image(https://d.pr/free/i/90mOOO)]]

 Here you can see that the John is the post author and is already logged in
 but he can't see the `Edit` link as he doesn't have the edit post
 capability. Though he can edit the post using our custom form which we
 should have been able to link using the
 `get_edit_post_link` if it fired.

 By allowing this patched filter we can do this from plugins without
 creating customized theme templates.  Hence, we should be able to get this
 result :
 [[Image(https://d.pr/free/i/xvITap)]]

 You can see that the default EDIT link now shows up and we can also
 customize the link using the `get_edit_post_link` filter.

 Hope I was clear enough about my view. Let me know if I have missed
 anything.

 Thanks

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/44017#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list