Skip to content

Instantly share code, notes, and snippets.

@mishterk
Last active January 20, 2022 02:04
Show Gist options
  • Save mishterk/47a3cc6b5dfc64aeb01fc308a03d2792 to your computer and use it in GitHub Desktop.
Save mishterk/47a3cc6b5dfc64aeb01fc308a03d2792 to your computer and use it in GitHub Desktop.
These snippets work together to allow us to add custom WooCommerce account menu links to any URL. See https://hookturn.io/add-custom-woocommerce-account-menu-links/ for more detail.
<?php
add_filter( 'woocommerce_get_endpoint_url', function ( $url, $endpoint, $value, $permalink ) {
if ( $endpoint === 'my-courses' ) {
$url = home_url( 'my-courses' );
}
return $url;
}, 10, 4 );
<?php
add_filter( 'woocommerce_account_menu_items', function ( $items, $endpoints ) {
$items['my-courses'] = 'My Courses';
return $items;
}, 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment