Hey @lepittenger
There may be a plugin out there that can do all that you need but you may be able to achieve what you need without a plugin
WordPress uses Roles and Capabilities to dictate what a user can and cannot do.
Take editing a page for example. Any user with a role of Editor or above will be able to do that so all you’d need to do is change the user’s role via the admin area.
Hope this helps!
Thanks for the reply @henrywright
I actually need to be able to allow a user to only have editing access to certain pages though. I don’t want them to be able to edit all of the pages, only the ones I give them access to
Thanks though
@lepittenger Right, I see now. Looking at wp_insert_post()
, all I can see that’s available to hook into is wp_insert_post_empty_content
Perhaps try something like this:
function lepittenger_custom_edit_page( $maybe_empty, $postarr ) {
// Your page ID here.
$page_id = 962;
// Your user ID here.
$user_id = 3;
// Get the post's info.
$post = get_post( $postarr['ID'] );
if ( ( $post->ID == $page_id ) && ( get_current_user_id() != $user_id ) )
return true;
}
add_action( 'wp_insert_post_empty_content', 'lepittenger_custom_edit_page', 10, 2 );
This is a bit cheeky because we’re tricking WP into thinking the post is empty which results in it aborting the update. But, I can’t think of a better way
Please note I haven’t tested.