How to remove the ability to add/edit products to vendors
If you want remove the ability to Vendor Role users to edit his "Slug" inside /wp-admin/admin.php?page=yith_vendor_settings please add this snippet of PHP code at the end of functions.php file:
add_action( 'init', 'yith_wcmv_remove_caps', 20 );
add_action( 'current_screen', 'yith_wcmv_disabled_manage_other_vendors_posts', 20 );
if( ! function_exists( 'yith_wcmv_remove_caps' ) ){
function yith_wcmv_remove_caps(){
if( function_exists( 'YITH_Vendors' ) ){
$vendor_role = YITH_Vendors()->get_role_name();
$role = get_role( $vendor_role );
if( $role instanceof WP_Role ){
$role->remove_cap( 'edit_products' );
}
}
}
}
if( ! function_exists( 'yith_wcmv_disabled_manage_other_vendors_posts' ) ){
function yith_wcmv_disabled_manage_other_vendors_posts() {
if ( isset( $_POST[ 'post_ID' ] ) || ! isset( $_GET[ 'post' ] ) ) {
return;
}
$post_id = $product_vendor = 0;
$vendor = yith_get_vendor( 'current', 'user' );
$post = get_post( $_GET['post'] );
$is_seller = $vendor->is_valid() && $vendor->has_limited_access();
if( $post && 'product' == $post->post_type && $is_seller ){
wp_die( sprintf( __( 'You do not have permission to edit this product. %1$sClick here to view and edit your products%2$s.', 'yith-woocommerce-product-vendors' ), '<a href="' . esc_url( 'edit.php?post_type=product' ) . '">', '</a>' ) );
}
}
}