16
November
2021
At some point you may want to customize the My Account page for your customers. In this video I take you through renaming, removing and adding custom tabs to your customer account page.
Functions for renaming and disabling tabs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <?php // Your PHP code goes here! //RENAME TAB add_filter( 'woocommerce_account_menu_items', 'handsomewp_rename_acc_tabs', 9999 ); function handsomewp_rename_acc_tabs( $items ) { //$items['edit-address'] = 'Your addresses'; //$items['dashboard'] = 'Account Home'; return $items; } //REMOVE OR DISABLE TAB add_filter( 'woocommerce_account_menu_items', 'handsomewp_remove_acc_tabs', 9999 ); function handsomewp_remove_acc_tabs( $items ) { //unset( $items['downloads'] ); //unset( $items['subscriptions'] ); return $items; } |
Functions for adding a custom tab:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | <?php // Your PHP code goes here! // 1. Register new endpoint // Note: Resave Permalinks or it will give 404 error function handsomewp_add_support_endpoint() { add_rewrite_endpoint( 'support', EP_ROOT | EP_PAGES ); } add_action( 'init', 'handsomewp_add_support_endpoint' ); // ------------------ // 2. Add new query function handsomewp_support_query_vars( $vars ) { $vars[] = 'support'; return $vars; } add_filter( 'query_vars', 'handsomewp_support_query_vars', 0 ); // ------------------ // 3. Insert the new endpoint function handsomewp_add_support_link_my_account( $items ) { $items['support'] = 'Support'; return $items; } add_filter( 'woocommerce_account_menu_items', 'handsomewp_add_support_link_my_account' ); // ------------------ // 4. Add content to the new endpoint function handsomewp_support_content() { echo '<h3>Support</h3><p>Welcome to the support area. As a premium customer, manage your support tickets from here, you can submit a ticket if you have any issues with your website. We\'ll put our best to provide you with a fast and efficient solution</p>'; //echo do_shortcode( '[your form plugin shortcode]' ); } add_action( 'woocommerce_account_support_endpoint', 'handsomewp_support_content' ); |
Leave a Reply