1

I'am developing WordPress theme and I can't figured it out why I can't add new custom capabilities for existing custom role without using any plugins for user

//Function for creating new custom capability


function map_custom_cap($roles = array()){

    foreach ( $roles as $role => $cap ) {

        $role->add_cap($cap);

    }
}

//This capabilities are not yet existing

        $reviewer_cap = array( 'read', 'edit_posts', 'delete_posts');

        $movie_author_cap = array( 'read_movie', 'edit_movies', 'delete_movies');

        $roles = array(
            'reviewer' => $reviewer_cap,
            'movie_author' => $movie_author_cap
        );

map_custom_cap($roles);
noviceRick
  • 121
  • 1
  • 5
  • 14
  • 2
    You are passing in the role name (`'reviewer'`), but using it as if it were a full role object. Use [`get_role()`](http://codex.wordpress.org/Function_Reference/get_role) to get the role object corresponding to the name, and call `add_cap` on that object. – DCoder Jul 28 '12 at 09:31
  • got it, I passed role name from array to get_role, now it works perfectly – noviceRick Jul 28 '12 at 15:31

0 Answers0