• Resolved Jason Wong

    (@eljkmw)


    It seems that the remove_menu_page( 'mm_wc_no_po_boxes' ); doesn’t work.
    How do I remove the menu page then?

    Please advise. Thank you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Maje Media LLC

    (@majemedia)

    Jason,

    You’ll have to hook in after the admin_menu action.

    According to the following document the admin_init action might be useful for you: https://codex.www.ads-software.com/Plugin_API/Action_Reference

    Thread Starter Jason Wong

    (@eljkmw)

    The following snippet is one that works. It wasn’t remove_menu_page, but the use of remove_submenu_page function instead.

    // Restrict submenu to all except admin
    function mmwc_restrict_submenu() {
    
    	// For non Administrator users
    	if ( !current_user_can( 'manage_options' ) ) {
    		remove_submenu_page( 'woocommerce', 'mm_wc_no_po_boxes' );
    	}
    }
    add_action( 'admin_menu', 'mmwc_restrict_submenu' );
    Plugin Author Maje Media LLC

    (@majemedia)

    Jason,

    Thanks for the snippet. We’ll get it into the next release to restrict the settings page to only users that are administrators.

    Plugin Author Maje Media LLC

    (@majemedia)

    Jason,

    We’ve added the issue to the plugin’s github project: https://github.com/MajeMediaLLC/MajeMedia-WC-No-PO-Boxes/issues/7

    Thread Starter Jason Wong

    (@eljkmw)

    In my opinion, having the snippet is better than to integrate it permanently into your next release. This way users can customise their own access level to your plugin’s settings.

    Plugin Author Maje Media LLC

    (@majemedia)

    While I agree with the sentiment of your comment it’s important to note that not locking down that interface is against the standard for WC & WP.

    I’ll go one step further, though and use a filter to allow for overriding the current_user_can option that gets used for the accessibility test.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to remove menu for non-admin’ is closed to new replies.