我已经购买了这个主题http://pixelgeeklab.com/wp-realestast/#all并希望在wordpress中添加新的用户名单,以便访问者可以注册到网站并添加自己的庄园。
我试着手动编码,但意识到这是一项艰巨的工作,我试着使用Justin Tadlock的成员插件(http://wordpress.org/plugins/members/)
我的问题是,我只能允许查看和编辑所有帖子,但不能编辑,所以访问者只能访问名为ESTATES的自定义帖子类型。
下面是functions.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,
));*/
//}
来自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/