我已经购买了这个主题 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 );