• Resolved jsojitra

    (@jsojitra)


    I’m using the free WC Vendor plugin and my vendor user does not access my Custom Post Type.

    Please suggest me how to access my custom post type in vendor user

Viewing 3 replies - 1 through 3 (of 3 total)
  • Jamie

    (@digitalchild)

    Hello,

    You will need to modify your vendor roles to include capabilities for that post type.

    cheers,

    Jamie.

    Thread Starter jsojitra

    (@jsojitra)

    Thanks digitalchild for the quick reply.

    I have modified vendor roles and include capabilities for my custom post in function.php file but still not access this post in my vendor dashboard.

    Here is my code snippet please suggest me where I wrong

    function custom_post_type(){
    $labels = array(
    ‘name’ => _x( ‘Request’, ‘post type general name’, ‘req’ ),
    ‘singular_name’ => _x( ‘Request’, ‘post type singular name’, ‘req’ ),
    ‘menu_name’ => _x( ‘Request’, ‘admin menu’, ‘req’ ),
    ‘name_admin_bar’ => _x( ‘Request’, ‘add new on admin bar’, ‘req’ ),
    ‘add_new’ => _x( ‘Add New’, ‘request’, ‘req’ ),
    ‘add_new_item’ => __( ‘Add New Request’, ‘req’ ),
    ‘new_item’ => __( ‘New Request’, ‘req’ ),
    ‘edit_item’ => __( ‘Edit Request’, ‘req’ ),
    ‘view_item’ => __( ‘View Request’, ‘req’ ),
    ‘all_items’ => __( ‘All Request’, ‘req’ ),
    ‘search_items’ => __( ‘Search Request’, ‘req’ ),
    ‘parent_item_colon’ => __( ‘Parent Request:’, ‘req’ ),
    ‘not_found’ => __( ‘No Request found.’, ‘req’ ),
    ‘not_found_in_trash’ => __( ‘No Request found in Trash.’, ‘req’ )
    );

    $args = array(
    ‘labels’ => $labels,
    ‘description’ => __( ‘Description.’, ‘req’ ),
    ‘public’ => true,
    //’publicly_queryable’ => true,
    ‘show_ui’ => true,
    ‘show_in_menu’ => true,
    ‘query_var’ => true,
    ‘rewrite’ => array( ‘slug’ => ‘request’ ),
    ‘capability_type’ => ‘post’,
    ‘menu_icon’ => ‘dashicons-awards’,
    ‘has_archive’ => true,
    ‘hierarchical’ => false,
    ‘menu_position’ => 57,
    ‘supports’ => array(”),
    ‘map_meta_cap’ => true,
    ‘capabilities’ => array(
    ‘read_post’ => ‘read_request’,
    ‘read_private_posts’ => ‘read_private_requests’,
    ‘edit_post’ => ‘edit_request’,
    ‘edit_posts’=> ‘edit_requests’,
    ‘edit_others_posts’=> ‘edit_others_requests’,
    ‘edit_published_posts’ => ‘edit_published_requests’,
    ‘edit_private_posts’ => ‘edit_private_requests’,
    ‘delete_post’ => ‘delete_request’,
    ‘delete_posts’ => ‘delete_requests’,
    ‘delete_others_posts’ => ‘delete_others_requests’,
    ‘delete_published_posts’ => ‘delete_published_requests’,
    ‘delete_private_posts’ => ‘delete_private_requests’,
    ‘publish_posts’ => ‘publish_requests’,
    ‘create_posts’ => true
    ),
    );
    register_post_type( ‘request’, $args );

    $admin = get_role( ‘administrator’ );
    $admin->add_cap( ‘read_request’ );
    $admin->add_cap( ‘read_private_request’ );
    $admin->add_cap( ‘edit_request’ );
    $admin->add_cap( ‘edit_requests’ );
    $admin->add_cap( ‘edit_others_requests’ );
    $admin->add_cap( ‘edit_published_requests’ );
    $admin->add_cap( ‘edit_private_requests’ );
    $admin->add_cap( ‘delete_requests’ );
    $admin->add_cap( ‘delete_request’ );
    $admin->add_cap( ‘delete_others_requests’ );
    $admin->add_cap( ‘delete_published_request’ );
    $admin->add_cap( ‘delete_request’ );
    $admin->add_cap( ‘delete_private_request’ );
    $admin->add_cap( ‘publish_requests’ );

    $role = get_role(‘vendor’);
    $role->add_cap( ‘read_request’ );
    $role->add_cap( ‘edit_request’ );
    $role->add_cap( ‘edit_requests’ );
    $role->add_cap( ‘delete_request’ );
    $role->add_cap( ‘delete_requests’ );
    $role->add_cap( ‘edit_private_requests’ );

    add_role( ‘vendor’, ‘vendor’, array(
    ‘read’ => true,
    ‘edit_posts’ => true,
    ‘delete_posts’ => true,
    ‘upload_files’ => true,
    ‘delete_published_posts’ => true,
    ‘publish_posts’ => true,
    ‘edit_published_posts’ => true)
    );
    }
    add_action(‘init’,’custom_post_type’);
    ?>

    Thanks.

    • This reply was modified 6 years, 6 months ago by jsojitra.
    Jamie

    (@digitalchild)

    Hello,

    The post types should show up in WP Admin automatically. if you want to show them on the vendor dashboard then you will need to edit the templates to add a link to add/edit that custom post type.

    WC Vendors only provides a simple dashboard, all product edits and CTP edits are performed in the WP admin area.

    cheers,

    Jamie.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WC Vendor user not show Custom Post’ is closed to new replies.