Created
October 25, 2017 09:33
-
-
Save geeac/63f36ae7f20709fac22692fded72caf1 to your computer and use it in GitHub Desktop.
custom endpoint My Account
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a custom end point in the My Accunt Page | |
function custom_wc_end_point() { | |
if(class_exists('WooCommerce')){ | |
add_rewrite_endpoint( 'wholesale-ordering', EP_ROOT | EP_PAGES ); | |
} | |
} | |
add_action( 'init', 'custom_wc_end_point' ); | |
function custom_endpoint_query_vars( $vars ) { | |
$vars[] = 'wholesale-ordering'; | |
return $vars; | |
} | |
add_filter( 'query_vars', 'custom_endpoint_query_vars', 0 ); | |
function ac_custom_flush_rewrite_rules() { | |
flush_rewrite_rules(); | |
} | |
function my_custom_my_account_menu_items( $items ) { | |
// Remove the logout menu item. | |
$logout = $items['customer-logout']; | |
unset( $items['customer-logout'] ); | |
// Insert your custom endpoint. | |
$items['wholesale-ordering'] = __( 'Wholesale Ordering', 'woocommerce' ); | |
// Insert back the logout item. | |
$items['customer-logout'] = $logout; | |
return $items; | |
} | |
add_filter( 'woocommerce_account_menu_items', 'my_custom_my_account_menu_items' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment