Support » Plugins » Hacks » capabilities problem for custom texonomy

  • Dear Sir,
    I have created new role. After that assign custom post type.when login this role base user then show custom post type and profile that is good.

    problem one:
    But when create taxonomy for this post type then only show that category .
    But does not create category those role user.

    problem two:
    after another problem is default post type category and tag show.That i do not want.

    i want only custom post type,taxonomy and profile when login that role base user.
    Please help me.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter padipetta

    (@padipetta)

    add_action( ‘init’, ‘register_custom_post_type’);
    function register_custom_post_type() {
    register_post_type( ‘publication’, array(
    ‘labels’ => array(
    ‘name’ => _x( ‘publications’, ‘post type general name’, ‘tuts-crm’ ),
    ‘singular_name’ => _x( ‘publication’, ‘post type singular name’, ‘tuts-crm’ ),
    ‘menu_name’ => _x( ‘publications’, ‘admin menu’, ‘tuts-crm’ ),
    ‘name_admin_bar’ => _x( ‘Publication’, ‘add new on admin bar’, ‘tuts-crm’ ),
    ‘add_new’ => _x( ‘Add New’, ‘publication’, ‘tuts-crm’ ),
    ‘add_new_item’ => __( ‘ADD NEW PUBLICATION NAME’, ‘tuts-crm’ ),
    ‘new_item’ => __( ‘New publication’, ‘tuts-crm’ ),
    ‘edit_item’ => __( ‘Edit publication’, ‘tuts-crm’ ),
    ‘view_item’ => __( ‘View publication’, ‘tuts-crm’ ),
    ‘all_items’ => __( ‘All publications’, ‘tuts-crm’ ),
    ‘search_items’ => __( ‘Search publications’, ‘tuts-crm’ ),
    ‘parent_item_colon’ => __( ‘Parent publications:’, ‘tuts-crm’ ),
    ‘not_found’ => __( ‘No publications found.’, ‘tuts-crm’ ),
    ‘not_found_in_trash’ => __( ‘No publications found in Trash.’, ‘tuts-crm’ ),
    ),

    // Frontend
    ‘has_archive’ => false,
    ‘public’ => false,
    ‘publicly_queryable’ => false,

    // Admin
    ‘capabilities’ => array(
    ‘edit_others_posts’ => ‘edit_others_publications’,
    ‘delete_others_posts’ => ‘delete_others_publications’,
    ‘delete_private_posts’ => ‘delete_private_publications’,
    ‘edit_private_posts’ => ‘edit_private_publications’,
    ‘read_private_posts’ => ‘read_private_publications’,
    ‘edit_published_posts’ => ‘edit_published_publications’,
    ‘publish_posts’ => ‘publish_publications’,
    ‘delete_published_posts’=> ‘delete_published_publications’,
    ‘edit_posts’ => ‘edit_publications’ ,
    ‘delete_posts’ => ‘delete_publications’,
    ‘edit_post’ => ‘edit_publication’,
    ‘read_post’ => ‘read_publication’,
    ‘delete_post’ => ‘delete_publication’,
    ),
    ‘map_meta_cap’ => true,
    ‘menu_icon’ => ‘dashicons-businessman’,
    ‘menu_position’ => 10,
    ‘query_var’ => true,
    ‘show_in_menu’ => true,
    ‘show_ui’ => true,
    ‘supports’ => array(
    ‘title’,
    ),
    )
    );
    }
    //PLACEHODER CHANGE FOR CUSTOM POST TYPE PUBLICATION
    function change_default_title( $title ){
    $screen = get_current_screen();
    if ( ‘publication’ == $screen->post_type ) {
    $title = ‘ENTER PUBLICATION TITLE’;
    }
    return $title;
    }
    add_filter( ‘enter_title_here’, ‘change_default_title’ );

    // Define our custom capabilities
    $customCaps = array(
    ‘edit_others_publications’ => true,
    ‘delete_others_publications’ => true,
    ‘delete_private_publications’ => true,
    ‘edit_private_publications’ => true,
    ‘read_private_publications’ => true,
    ‘edit_published_publications’ => true,
    ‘publish_publications’ => true,
    ‘delete_published_publications’ => true,
    ‘edit_publications’ => true,
    ‘delete_publications’ => true,
    ‘edit_publication’ => true,
    ‘read_publication’ => true,
    ‘delete_publication’ => true,
    ‘read’ => true,
    ‘upload_files’ => true

    );
    // Create our CRM role and assign the custom capabilities to it
    add_role( ‘professor’, __( ‘Professor’, ‘tuts-crm’), $customCaps );

    // Add custom capabilities to Admin and Editor Roles
    $roles = array( ‘administrator’, ‘editor’ );
    foreach ($roles as $roleName) {
    // Get role
    $role = get_role( $roleName );
    // Check role exists
    if ( is_null( $role) ) {
    continue;
    }
    // Iterate through our custom capabilities, adding them
    // to this role if they are enabled
    foreach ( $customCaps as $capability => $enabled ) {
    if ( $enabled ) {
    // Add capability
    $role->add_cap( $capability );
    }
    }
    }

    Thread Starter padipetta

    (@padipetta)

    Above code is good for only post type.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘capabilities problem for custom texonomy’ is closed to new replies.