// Add new tab to My Account menu
add_filter ( 'woocommerce_account_menu_items', 'wpsh_custom_endpoint', 40 );
function wpsh_custom_endpoint( $menu_links ){
$menu_links = array_slice( $menu_links, 0, 5, true )
// Add your own slug (delete-account, for example) and tab title here below
+ array( 'delete-account' => 'Delete My Account' )
+ array_slice( $menu_links, 5, NULL, true );
return $menu_links;
}
// Let’s register this new endpoint permalink
add_action( 'init', 'wpsh_new_endpoint' );
function wpsh_new_endpoint() {
add_rewrite_endpoint( 'Delete My Account', EP_PAGES ); // Don’t forget to change the slug here
}
// Now let’s add some content inside your endpoint
add_action( 'woocommerce_account_delete-account_endpoint', 'wpsh_endpoint_content' );
function wpsh_endpoint_content() {
// At the moment I will add delete my account shordcode
echo do_shortcode('[plugin_delete_me]Delete Your Account[/plugin_delete_me]');
}
// NB! In order to make it work you need to go to Settings > Permalinks and just push "Save Changes" button.
// If you need to change endpoint order then add your own order here
add_filter ( 'woocommerce_account_menu_items', 'wpsh_custom_endpoint_order' );
function wpsh_custom_endpoint_order() {
$myorder = array(
'dashboard' => __( 'Painel', 'woocommerce' ),
'orders' => __( 'Encomendas', 'woocommerce' ),
'edit-account' => __( 'Detalhes da Conta', 'woocommerce' ),
'edit-address' => __( 'Editar Morada', 'woocommerce' ),
'wishlist' => __( 'Wishlist', 'woocommerce' ),
'delete-account' => __( 'Eliminar Conta', 'woocommerce' ), // Don’t forget to change the slug and title here
'customer-logout' => __( 'Log out', 'woocommerce' ),
);
return $myorder;
}