jeudi 3 novembre 2016

Display a Tab on the woocommerce my account page conditionally

Hello I was able to create a custom endpoint on the woocommerce my account page:

    function my_custom_my_account_menu_items( $items ) {
    $items = array(
        'dashboard'         => __( 'Dashboard', 'woocommerce' ),
        'orders'            => __( 'Orders', 'woocommerce' ),
        //'downloads'       => __( 'Downloads', 'woocommerce' ),
        //'edit-address'    => __( 'Addresses', 'woocommerce' ),
        //'payment-methods' => __( 'Payment Methods', 'woocommerce' ),
        'edit-account'      => __( 'Edit Account', 'woocommerce' ),
        'special-page'      => 'Special Page',
        'customer-logout'   => __( 'Logout', 'woocommerce' ),
    );

    return $items;
}

add_filter( 'woocommerce_account_menu_items', 'my_custom_my_account_menu_items' );

I visited the following urls: http://ift.tt/2fGWFpV WooCommerce: Assigning an endpoint to a custom template in my account pages

Now I would like to know how I can display a tab conditionally based on the user role? I would like to display the "Special Page" tab only for vendors.

if ( ! current_user_can( 'vendor' ) ) {}

Any ideas how to achieve this?

Nicholas

Aucun commentaire:

Enregistrer un commentaire