[英]Adding new user roll in WordPress that can only add custom posts
I have purchased this theme http://pixelgeeklab.com/wp-realestast/#all and would like to add new user roll in wordpress so visitors can register to the website and add their own estates. 我已经购买了这个主题http://pixelgeeklab.com/wp-realestast/#all,并希望在wordpress中添加新的用户名册,以便访问者可以注册到该网站并添加自己的财产。
I tried manually coding this but realized thah is a LOT of work and I tried using the members plugin by Justin Tadlock ( http://wordpress.org/plugins/members/ ) 我尝试手动编码,但意识到这是很多工作,我尝试使用Justin Tadlock( http://wordpress.org/plugins/members/ )的成员插件
My problem is that I can enable only ALL posts to be viewed and edited but can't edit so that visitor can only have access to custom post type called ESTATES. 我的问题是,我只能查看和编辑所有帖子,但不能编辑,因此访问者只能访问名为ESTATES的自定义帖子类型。
Underneath find the code from functions.php (I tried a lot, so if someone could see this and clear the code, I would be very grateful): 在函数(php)的下面找到代码(我做了很多尝试,所以如果有人可以看到并清除代码,我将不胜感激):
add_action('init', 'wptuts_getrole');
function wptuts_getrole() {
$role = get_role('seller');
echo '<pre>';
var_dump($role);
echo '</pre>';
}
add_action( 'init', 'ct_add_role' );
function ct_add_role() {
$role = get_role( 'seller' );
$role->remove_cap('edit_posts');
$role->add_cap('read');
$role->add_cap('manage_options');
$role->add_cap('publish_posts');
$role->add_cap('add_estates');
$role->add_cap('edit_estate');
/*add_role('seller', 'Seller', array(
'read' => true,
'add_posts'=> false,
'publish_posts' => false,
'edit_posts' => false,
'delete_posts' => false,
'add_estate'=> false,
'manage_options'=>false,
));*/
//}
And the code from estates.php: 以及来自estates.php的代码:
/**
* #####################################
* Actions
* #####################################
*/
static function register() {
$args = array(
'labels' => array(
'name' => 'Estates',
'singular_name' => 'Estate',
),
'description' => __( 'This post type is used in RealEstast theme', PGL ),
'public' => TRUE,
'show_ui' => TRUE,
'hierarchical' => FALSE,
/* 'capability_type' => 'post',
'capability' => array(
'add_posts' => 'add_estates',
'publish_posts' => 'publish_estates',
'edit_posts' => 'edit_estates',
'edit_others_posts' => 'edit_others_estates',
'delete_posts' => 'delete_estates',
'delete_others_posts' => 'delete_others_estates',
'read_private_posts' => 'read_private_estates',
'edit_post' => 'edit_estate',
'delete_post' => 'delete_estate',
'read_post' => 'read_estate',
),*/
'supports' => array(
'title',
'editor',
'thumbnail',
),
'has_archive' => TRUE,
'rewrite' => array(
'slug' => 'estate',
'with_front' => TRUE
),
);
register_post_type( 'estate', $args );
您可以尝试使用此插件,它应该可以满足您的所有要求http://wordpress.org/plugins/advanced-access-manager/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.