… may be a solution could be to create a user-capabilty
‘edit_published_posts_of_user_id_X‘
but how to do this?
🙂
Thank you
Frank
Replace:
return $allow && in_category( 'wiki', $data['post_id'] );
with:
return current_user_can( 'some_custom_capability' );
The capability can be added to a certain role, using a plugin like Capability Manager.
Hi,
‘front_end_editor_allow_post’ is not fired, if user has no capabilities:
-> (1) ‘edit_other_php’ and
-> (2) ‘edit_other_posts’
—
So, whatever I put into the function below, it does not work:
function fee_extend_user_post_cap( $allow, $data ) {
return current_user_can( 'edit_dummy_posts');
}
add_filter( 'front_end_editor_allow_post', 'fee_extend_user_post_cap', 2, 10);
—
If I grant my user group (e.g. role ‘ABC-users’) in Capability Manager with capabilities:
-> (1) ‘edit_other_php’ and
-> (2) ‘edit_other_posts’
FEE works fine for the posts from the placeholder/dummy-author. But, now ABC-user can edit posts from all other authors too, and not only in FEE but the same in dashboard. Strange! This cannot be the solution …
—
What I need is a specific capability like ‘edit_dummy_posts_of_author_X’, which is RESTRICTED to author X only!
This should be work for FEE (however it will not be a problem if this works in dashboard too).
May be it is not a specific FEE-problem, but it would be great if you could give me some advice, how to realize that!
Frank
I’ve got it working assigning caps on specific pages, like:
if($some_page_specific_permission) {
global $wp_roles;
$wp_roles->add_cap( 'ABC-user', 'edit_others_posts' );
$wp_roles->add_cap( 'ABC-user', 'edit_others_php' );
}
FEE allows now ABC-user to edit other authors post.
Frank
Stupid solution! I thought permission would be granted once for the current page only. This was a first-class mistake. Permissions are granted for the future at all!
As this does not work, I found a solution modifiing function check() in scribu’s post.php:
function check( $post_id = 0 ) {
if ( is_array( $post_id ) )
extract( $post_id );
// added 5 rows: allows editing of placeholder-posts (who ever posted it, but containing 'some specific chars' in the post_title)
// restrict to user group 'abc-user' (example)
if(current_user_can('is-abc-user'))
$my_post_title = get_post_field( 'post_title', $post_id );
if(!(false===strpos(strtolower($my_post_title), $some_specific_chars)))
return true;
else
// --
return current_user_can( 'edit_post', $post_id);
}
If someone has a suggestion how to realize this outside the plugin, I would appreciate it very much!
Frank
You’ve got all the info you need in front_end_editor_allow_post:
function fee_alter_check( $allow, $data ) {
$post_id = $data['post_id];
// added 5 rows: allows editing of placeholder-posts (who ever posted it, but containing 'some specific chars' in the post_title)
// restrict to user group 'abc-user' (example)
if(current_user_can('is-abc-user'))
$my_post_title = get_post_field( 'post_title', $post_id );
if(!(false===strpos(strtolower($my_post_title), $some_specific_chars)))
return true;
else
// --
return current_user_can( 'edit_post', $post_id);
}
add_filter( 'front_end_editor_allow_post', 'fee_alter_check', 10, 2 );
Putting that code in your theme’s functions.php file should have the exact same effect.