Error adding menu to Vendor Dashboard
-
Hello, i’m developing a addon for yith Multi Vendor but i’m having problems creating new menus inside Vendor Dashboard:
I trying to use this code:
function my_vendor_menu() {
add_menu_page( ‘My menu’,
‘My menu’,
‘yith_vendor’,
‘my_slug’,
‘function_form’,
‘dashicons-admin-users’,
’65’
);
}
add_action( ‘admin_menu’,’my_vendor_menu’ , 5);But menu is not displayed inside Vendor Dashboard, if i replace “yith_vendor” with “Administrator”, menu is displayed inside Admin Dashboard ok. Y tried also using “manage_options” , with same result.
Thanks in advance!
-
Any help?
Hi there,
Try to use “edit_products” as capability.
Hi, thanks for reponse, i tried with: edit_products , read, read_shop_order and menu keep hidden, but is displayed in admin dashboard correctly.
for example:function at_menu_vendor () {
add_menu_page( ‘Services Report’,
‘Services Report’,
‘read_shop_order’ ,
‘services_report’,
‘at_report_vendor’,
‘dashicons-admin-users’,
’65’
);}
add_action( ‘admin_menu’,’at_menu_vendor’ , 6);
Hi there,
for this you can use a code like this:
if( ! function_exists( 'yith_wpv_vendor_menu_items' ) ){ function yith_wpv_vendor_menu_items( $to_add ) { if( function_exists( 'yith_get_vendor' ) ){ $vendor = yith_get_vendor( 'current', 'user' ); if ( $vendor->is_valid() && $vendor->has_limited_access() ) { $user = wp_get_current_user(); /* === Change This With Your Custom Page === */ $to_add[] = 'edit.php?post_type=page'; } } return $to_add; } } add_filter( 'yith_wpv_vendor_menu_items', 'yith_wpv_vendor_menu_items' );Please, remember to change this line of code:
$to_add[] = 'edit.php?post_type=page';with your custom page.
Let me know if works.Hi, thanks for response, i used your code but it not display menu in vendor dasboard, i used this:
if( ! function_exists( 'yith_wpv_vendor_menu_items' ) ){
function yith_wpv_vendor_menu_items( $to_add ) {
if( function_exists( 'yith_get_vendor' ) ){
$vendor = yith_get_vendor( 'current', 'user' );
if ( $vendor->is_valid() && $vendor->has_limited_access() ) {
$user = wp_get_current_user();
/* === Change This With Your Custom Page === */
$to_add[] = 'at_vendor_info';
}
}return $to_add;
}
}add_filter( 'yith_wpv_vendor_menu_items', 'yith_wpv_vendor_menu_items' );
Please, could you send to me the full code that you have used to add this new menu item ? Are you sure that at_vendor_info is the correct page slug ?
This is my code, i have a question with your code, where i set name for menu, functions to render content, etc? Thanks!
<?php /* Plugin Name: Addon to YMV Plugin URI: https://implicitpay.com Description: Addon to YMV Version: 0.1 Author: Atma Author URI: https://www.implicitpay.com/ License: GPLv2 o posterior */ if( ! function_exists( 'yith_wpv_vendor_menu_items' ) ){ function yith_wpv_vendor_menu_items( $to_add ) { if( function_exists( 'yith_get_vendor' ) ){ $vendor = yith_get_vendor( 'current', 'user' ); if ( $vendor->is_valid() && $vendor->has_limited_access() ) { $user = wp_get_current_user(); /* === Change This With Your Custom Page === */ $to_add[] = 'at_vendor_info'; } } return $to_add; } } add_filter( 'yith_wpv_vendor_menu_items', 'yith_wpv_vendor_menu_items' ); ?>-
This reply was modified 7 years, 3 months ago by
atmanivedana.
Hi there,
Please, try this code. However, I think you must add the code to new menu item in this plugin, too.
<?php /* Plugin Name: Addon to YMV Plugin URI: https://implicitpay.com Description: Addon to YMV Version: 0.1 Author: Atma Author URI: https://www.implicitpay.com/ License: GPLv2 o posterior */ if( ! function_exists( 'yith_wpv_vendor_menu_items' ) ){ function yith_wpv_vendor_menu_items( $to_add ) { if( function_exists( 'yith_get_vendor' ) ){ $vendor = yith_get_vendor( 'current', 'user' ); if ( $vendor->is_valid() && $vendor->has_limited_access() ) { $user = wp_get_current_user(); /* === Change This With Your Custom Page === */ $to_add[] = 'at_vendor_info'; } } return $to_add; } } if( ! function_exists( 'yith_wcmv_custom_code' ) ){ function yith_wcmv_custom_code(){ add_filter( 'yith_wpv_vendor_menu_items', 'yith_wpv_vendor_menu_items' ); } } add_action( 'init', 'yith_wcmv_custom_code', 20 );Let me know.
-
This reply was modified 7 years, 3 months ago by
The topic ‘Error adding menu to Vendor Dashboard’ is closed to new replies.