wordpress-bootstrap icon indicating copy to clipboard operation
wordpress-bootstrap copied to clipboard

allow editing post based on user level

Open GerritKuilder opened this issue 13 years ago • 7 comments

I noticed that user_level is used to check if user can edit post, is this correct method? Does this mean that aothers of smae level can edit eachothers post and not only the ones they wrote?

GerritKuilder avatar Mar 03 '12 09:03 GerritKuilder

I just confirmed that the edit button shows up on all articles if an author is logged in, when in the admin panel a logged in author can only edit their own articles. I consider this pretty major

GerritKuilder avatar Mar 03 '12 10:03 GerritKuilder

I think this commit causes the issue: https://github.com/320press/wordpress-bootstrap/commit/acc7ce0c142008d5397b28695d61096e6d79c3c7#single.php

edit_post_link handles displaying the Edit link to authorized users automatically.

mindctrl avatar Mar 03 '12 13:03 mindctrl

In order to get the nice button the <a tag needs the label, so an override for the eodt_pos_link should be made. Starangely enough the button shows only up on Chrome/linux, I did not see it on my windows machine.

GerritKuilder avatar Mar 04 '12 08:03 GerritKuilder

You can get the custom class on edit_post_link by doing this in functions.php

/* Add class to edit button */
function my_custom_edit_post_link($output) {
 $output = str_replace('class="post-edit-link"', 'class="post-edit-link btn btn-success"', $output);
 return $output;
}
add_filter('edit_post_link', 'my_custom_edit_post_link');

mindctrl avatar Mar 04 '12 13:03 mindctrl

To be more precise (to get the hover effect)

/* Add class to edit button */
function gk_edit_post_link($output) {
 $output = str_replace('class="post-edit-link"', 'class="post-edit-link btn btn-success" style="display: none;"', $output);
 return $output;
}
add_filter('edit_post_link','gk_edit_post_link');

GerritKuilder avatar Mar 04 '12 13:03 GerritKuilder

My hover effect works without that extra style. If by hover effect you mean the subtle color change? In fact, your code makes my button not show at all.

mindctrl avatar Mar 04 '12 13:03 mindctrl

I'm sorry you are right. no "display:none" needed... Oops I spoke too soon, with display:none it does Sweet FA, without it the button always shows. Might be a plugin I use (code used on devel.kuilder.net/bootstrap in the first child theme. (and I am logged in as admin.) I had it working for a bit....

And originally the button would only who when you hovered over p-arts of the article.

GerritKuilder avatar Mar 04 '12 13:03 GerritKuilder