• Resolved calle81

    (@calle81)


    This plugin is fantastic.

    I use the function:

    add_filter ('fep_menu_buttons', 'fep_cus_fep_menu_buttons', 99);
    
    function fep_cus_fep_menu_buttons ($menu)
    {
    ???? unset ($menu ['settings']);
    ???? return $menu;
    }

    I was wondering if it’s possible to hide the setting button, only if the value of a user field is <11. I tried to write this:

    add_filter( 'fep_menu_buttons', function( $menu ){
        $user = wp_get_current_user();
        if(strlen(get_the_author_meta( $user->ID, 'customfield', true ))<11)
        unset( $menu['setting'] );
        return $menu;
    }, 99);

    It does not work though! I’m not a programmer, can you help me? I would be very grateful. thank you.

    • This topic was modified 6 years, 9 months ago by calle81. Reason: Translate
    • This topic was modified 6 years, 9 months ago by calle81.
    • This topic was modified 6 years, 9 months ago by calle81. Reason: New code
    • This topic was modified 6 years, 9 months ago by calle81.
    • This topic was modified 6 years, 9 months ago by calle81.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Shamim Hasan

    (@shamim51)

    Try following

    add_filter( 'fep_menu_buttons', function( $menu ){
        $user = wp_get_current_user();
        if( $user->customfield < 11 ){
            unset( $menu['setting'] );
        }
        return $menu;
    }, 99);
    
    Thread Starter calle81

    (@calle81)

    I had forgotten a {.

    add_filter ('fep_menu_buttons', function ($ menu) {
    $ user = wp_get_current_user ();
    if (strlen (get_user_meta ($ user-> ID, 'customfield', true)) <11) {
    unset ($ menu ['setting']);
    }
    return $ menu;
    }, 99);

    Now it works perfectly.

    Thanks for the support.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hide button menu ‘setting’.’ is closed to new replies.