Skip to content

Instantly share code, notes, and snippets.

@samholguin
Created April 10, 2018 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samholguin/7265ea68ab309b7436ef0294774b7c70 to your computer and use it in GitHub Desktop.
Save samholguin/7265ea68ab309b7436ef0294774b7c70 to your computer and use it in GitHub Desktop.
WordPress - add admin page endpoint
/**
* Account menu items.
*
* @param arr $items
*
* @return arr
*/
function swd_account_menu_items($items)
{
$items['profile'] = 'Profile';
return $items;
}
add_filter('woocommerce_account_menu_items', 'swd_account_menu_items', 10, 1);
/**
* Add 'profile' endpoint.
*/
function swd_wc_add_my_account_endpoint()
{
add_rewrite_endpoint('profile', EP_PAGES);
}
add_action('init', 'swd_wc_add_my_account_endpoint');
/**
* My Account > profile content.
*/
function swd_wc_profile_endpoint_content()
{
wc_get_template('myaccount/profile.php');
}
add_action('woocommerce_account_profile_endpoint', 'swd_wc_profile_endpoint_content');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment