capability doesn’t work with woocommerce plugin
-
site: localhost
theme: wordpress default theme (twentytwentyone)
custom role and capability doesn’t work with woocommerce.
im trying to open the option page(localhost/wp-admin/admin.php?page=product_manager) but it redirect to localhost/my-account/
add_action( 'admin_menu', function() { remove_role( 'custom_role' ); add_role( 'custom_role', 'custom role', array( 'custom_capability' => true, ) ); add_menu_page( 'title' , // page title 'custom title' , // menu title 'custom_capability' , // capability "product_manager" , // slug 'option_template' , // page content ); }); function option_template() { echo "string"; }
and if i use one of wordpress role capability like ‘edit_posts’ . it works fine
add_action( 'admin_menu', function() { remove_role( 'custom_role' ); add_role( 'custom_role', 'custom role', array( 'custom_capability' => true, 'edit_posts' => true ) ); add_menu_page( 'title' , // page title 'custom title' , // menu title 'edit_posts' , // capability "product_manager" , // slug 'option_template' , // page content ); }); function option_template() { echo "string"; }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘capability doesn’t work with woocommerce plugin’ is closed to new replies.