Capabilities in WP 2 / Create and Delete capabilities

  • Author
  • #28085


    Hi there,

    one of the most anoying things in WP 2 are an missing out-of-the-box role editor (there is an plugin, but it is not perfect at all because of many weaknesses in the WP2 role/capabilitiy system – e.g. some capabilities are bound to a specific named role and not to the capability itself) – but much more i miss a finer control over the capabilities.

    I spend lots of time to find plugins for limiting categories or pages but i was not satisfied at all because (for example) “restrict pages” from Owen Winkler does not disable the creation of new pages – and that is not possible without modifying the code of a WP 2 admin component (page-new.php) because WP2 thinks that “edit” capabilities are also “create” capabilities – not really useful.

    A small hack for this (which works fine with WP 2.0.4) follows (it is an adaption of Owen Winklers “restrict_pages.php”):

    In “page-new.php” you have to modify the line that looks like:

    if ( current_user_can('edit_pages') ) {

    if ( current_user_can('create_pages') ) {

    then you have to add the following script to your plugin folder (it should have the name “restrict_create_pages.php”:

    Plugin Name: Restrict Page Creation
    Description: Restricts users from creating Pages unless they have create pages capability
    Version: 0.1
    Author: Axel Napolitano
    Author URI:
    Plugin URI:

    class Restrict_Create_Pages
    function Restrict_Create_Pages()
    add_filter('user_has_cap', array(&$this, 'user_has_cap'), 10, 3);
    add_filter('capabilities_list', array(&$this, 'capabilities_list'));

    function user_has_cap()
    global $post, $current_user;
    $vargs = func_get_args();
    list($allcaps, $reqcaps, $args) = $vargs;

    if(($reqcaps[0] == 'create_pages') && $allcaps['create_pages'] == 1)
    return $allcaps;
    else if(($reqcaps[0] == 'create_pages') && $allcaps['create_pages'] != 1)
    $allcaps = array();
    return $allcaps;

    function capabilities_list($caplist)
    $caplist[] = 'create_pages';
    return $caplist;

    $restrict_create_pages = new Restrict_Create_Pages();



    Any user (also the admin-user) without the “create_pages” capability will loose the ability to create new pages. In case of an accident, you can safely rename or delete the plugin from your plugins folder to disable its functionality. It is best used with the installed role editor from Owen Winkler.

    Suggestion and Idea:

    • Extend the capability system. Add the capabilities “create” and “delete” to allow a finer control if neccessary.



    Rick Deckart



    ummm you’re in the wrong forum if you’re either self hosted or web hosted you need to be over here



    might be possible … maybe i am to fast. “Ideas” seems to be a good place for an idea ;-) But maybe this “Ideas” forum is not for improvement stuff … Forgive me, please !



    But maybe this “Ideas” forum is not for improvement stuff …

    It is but we’re talking different software though. :)

The topic ‘Capabilities in WP 2 / Create and Delete capabilities’ is closed to new replies.