0

USER01 is not showing in Author drop down list while editing a Page if he's in the my custom ROLE "mycustomrole".

If I change his role as an AUTHOR, and add the very same custom and non custom capacities, he's shown in the list.

I created this role programatically, as shown below.

Is there something particular to add in order to see it in my Authors list?

function cjg_4cast_addroles(){
    cjg_add_role('mycustomrole','My Custom Role',array(
        array('singular' => 'side-add', 'plural' => 'side-adds'),
        array('singular' => 'partner', 'plural' => 'partners')
        ),
        array(
            'read' => true,
            'upload_files' => true,
            'edit_files' => true,
            'edit_pages' => true,
            'edit_published_pages' => true,
            'publish_pages' => true,
            'delete_pages' => true,
            'delete_private_pages' => true,
            'edit_private_pages' => true,
            'read_private_pages' => true,
            'publish_posts' => true,
            'edit_posts' => true,
            'edit_published_posts' => true,
        )
    );
}

function cjg_add_role($role_name,$role_name_display,$custom_type_slugs,$capabilities){

    foreach($custom_type_slugs as $custom_type_slug){
        $capabilities = array_merge($capabilities,
            cjg_capabilitiesarray_fromslug($custom_type_slug['singular'],$custom_type_slug['plural'])
            );
    }

    add_role( $role_name, $role_name_display, $capabilities);
}

function cjg_capabilitiesarray_fromslug($singular,$plural){

    return array(
        "edit_$singular" => true,
        "read_$singular" => true,
        "delete_$singular" => true,
        "edit_$plural" => true,
        "edit_others_$plural" => true,
        "publish_$plural" => true,
        "read_private_$plural" => true,
    );
}
2
  • why a down vote? I still need to find an answer, I found other posts with the same issue and no solution
    – Christian
    Commented Nov 6, 2012 at 13:38
  • I up voted, valid question. Came across a similar problem. Commented Oct 2, 2013 at 15:03

2 Answers 2

1

the answer is provided here: Users with custom roles not showing in post author select box

I tested and it works:

to add a level_1 cap to your role.

It's PITA, considering how user levels have been deprecated so long ago, but there you go
1
  • I'm taking a plane, I'll copy paste real code later eventually
    – Christian
    Commented Oct 3, 2013 at 17:44
0

Not sure, but could the issues have to do with spelling "plural" as "plurial"?? I know that you are using it as a variable name in your functions, but you also reference it in the cjg_add_role function...

1
  • thanks. Sorry for the mispel, since I kept to my mistake all along and it's only a variable name, I don't see how it could influence. It could have if I had changed it in some other place, but I didn't know the spelling was wrong
    – Christian
    Commented Oct 4, 2012 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.