致命错误:在非对象上调用成员函数add_cap()

时间:2012-07-28 09:21:32

标签: wordpress capability

我正在开发WordPress主题,我无法弄清楚为什么我不能为现有自定义角色添加新的自定义功能而不使用任何用户插件

//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);

0 个答案:

没有答案