Home Forums WC Vendors Pro Support Display a tab conditionally based on user role

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #46727
    Nicholas
    Participant

    Hello there @WCV

    I was able to place the [wcv_pro_dashboard] inside a woocommerce tab.

    function my_custom_my_account_menu_items( $items ) {
    $items = array(
    ..
    'pro_dashboard' => 'Dashboard',
    ..
    );
    
    return $items;
    }
    
    add_filter( 'woocommerce_account_menu_items', 'my_custom_my_account_menu_items' );
    function woo_new_product_tab__dashboard_content() {
    
    	// The new tab content
    
    	echo do_shortcode( '[wcv_pro_dashboard]' );
    }

    My question now is: How to make the tab display conditionally based on the user role?

    WCV_Vendors::is_vendor( get_current_user_id() )

    Thank you for your time and help.

    Nicholas

    #46907
    Nicholas
    Participant

    Hey guys. I just wanted to let you know that I got it to work. In case anyone else is interested, heres my code:

    // Woocommerce My Account 
    
    function my_custom_endpoints() {
        add_rewrite_endpoint( 'your-endpoint', EP_ROOT | EP_PAGES );
    }
    
    add_action( 'init', 'my_custom_endpoints' );
    
    function my_custom_query_vars( $vars ) {
        $vars[] = 'your-endpoint';
    
        return $vars;
    }
    
    add_filter( 'query_vars', 'my_custom_query_vars', 0 );
    
    function my_custom_flush_rewrite_rules() {
        flush_rewrite_rules();
    }
    
    add_action( 'after_switch_theme', 'my_custom_flush_rewrite_rules' );
    
    //Menu Items 
    function my_custom_my_account_menu_items( $items, $new_items ) {
    
        $items = array(
            'dashboard'         => __( 'Home', 'woocommerce' ),
            'orders'            => __( 'Bestellungen', 'woocommerce' ),
            //'downloads'       => __( 'Downloads', 'woocommerce' ),
            //'edit-address'    => __( 'Adresse', 'woocommerce' ),
            //'payment-methods' => __( 'Zahlungsmethoden', 'woocommerce' ),
            //'edit-account'      => __( 'Kontoeinstellungen', 'woocommerce' ),
            //'your-endpoint'      => 'Your Endpoint',
            //'customer-logout'   => __( 'Logout', 'woocommerce' ),
        );
        
        $new_items = array(
        'dashboard'         => __( 'Home', 'woocommerce' ),
        'your-endpoint'      => 'Your Endpoint',
        
        );
        
     if ( current_user_can( 'subscriber' ) ) {
        return $items;
    }
    else {
    return $new_items;
    }
    
    }
    
    add_filter( 'woocommerce_account_menu_items', 'my_custom_my_account_menu_items' );
    
    //Custom Endpoint Content
    function my_custom_endpoint_content() {
        
    
    echo do_shortcode ('[wcv_pro_dahsboard]');
    }
    
    add_action( 'woocommerce_account_your-endpoint_endpoint', 'my_custom_endpoint_content' );
    

    I hope this helps someone…

    #46936
    Anna
    Member

    Awesome- glad you got it to work the way you wanted it to be for your site. Thank you for sharing!!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.