• This code doesnt work and it just hiding the menu link

    function my_remove_menu_pages() {
    	remove_menu_page( 'wc-admin&path=/marketing' );
    }

    SO, i want to do this with a filter. i wrote this code. what’s the issue with this code? it doesnt work

    add_filter( 'woocommerce_admin_features', function( $features ) {
        return array_values(
            array_filter( $features, function($feature) {
    	$user = wp_get_current_user();
        		if($user && isset($user->user_login) && 'Reception' == $user->user_login) { 
                	return $feature !== 'marketing';
    			}
            } ) 
        );
    } );
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support con

    (@conschneider)

    Engineer

    Hi there,

    what’s the issue with this code? it doesnt work

    You can try and find out by simplifying your function.

    
    add_filter( 'woocommerce_admin_features', function( $features ) {
        return array_values(
            array_filter( $features, function($feature) {
                	return $feature !== 'marketing';
            } ) 
        );
    } );

    Does this work for all users?

    Kind regards,

    Thread Starter shenalorlof

    (@shenalorlof)

    Hi supporter, yeah the code you dropped works with every user. As an example there’s a user called reception with admin role there. I want this to be worked only with that user. Based on the username ‘Reception’

    -Regards

    • This reply was modified 3 years, 8 months ago by shenalorlof.

    Hi @shenalorlof

    I can also recommend the following places for more development-oriented questions:

    WooCommerce Slack Community: https://woocommerce.com/community-slack/
    WooCommerce Community on Facebook: https://www.facebook.com/groups/advanced.woocommerce/

    Or, you could also contact one of the services on our Customizations page to get help with custom coding : https://woocommerce.com/customizations/

    Thread Starter shenalorlof

    (@shenalorlof)

    Everyday when u reply @maykato u come up with saying the same thing which is hire a developer. that’s all u know to say and u paste here. u should have let someone who knows work as @conschneider to reply without interfering. ???? even if it takes months it’s ok that we can get a solution so at least someone else can use if it is too late for me.

    Thank You

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Remove Marketing Menu link based on the username’ is closed to new replies.