Limit WordPress user to edit only his own pages

I’m looking for the simplest way to limit a WordPress user to edit only his own pages (that is pages he is author of). I’ve read about some users manager plugins but for my needs they seems overkill and so I wonder if it is possible to obtain the same result adding some code lines to functions.php or something similar.

Related posts

Leave a Reply

1 comment

  1. you can do this by adding a new role like so :

    <?php add_role( $role, $display_name, $capabilities ); ?> 
    

    This setting is saved to the database (in table wp_options, field wp_user_roles), so it might be better to run this on theme/plugin activation

    Returns a WP_Role object on success, null if that role already exists.

    Example

    Create a new “Basic Contributor” role.

    $result = add_role(
        'basic_contributor',
        __( 'Basic Contributor' ),
        array(
            'read'         => true,  // true allows this capability
            'edit_posts'   => true,
            'delete_posts' => false, // Use false to explicitly deny
        )
    );
    if ( null !== $result ) {
        echo 'Yay! New role created!';
    }
    else {
        echo 'Oh... the basic_contributor role already exists.';
    }
    

    add_role() is located in wp-includes/capabilities.php.

    for more clarification look in this article