php - Adding new user roll in WordPress that can only add custom posts -
i have purchased theme http://pixelgeeklab.com/wp-realestast/#all , add new user roll in wordpress visitors can register website , add own estates.
i tried manually coding realized thah lot of work , tried using members plugin justin tadlock (http://wordpress.org/plugins/members/)
my problem can enable posts viewed , edited can't edit visitor can have access custom post type called estates.
underneath find code functions.php (i tried lot, if see , clear code, grateful):
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 code estates.php:
/** * ##################################### * actions * ##################################### */ static function register() { $args = array( 'labels' => array( 'name' => 'estates', 'singular_name' => 'estate', ), 'description' => __( 'this post type 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 );
you try plugin, should need http://wordpress.org/plugins/advanced-access-manager/
Comments
Post a Comment