How to add custom endpoint to Dashboard's page

I’m not a php developer but I guess this post will help many people: I’m using this snippet code below to try to add a new endpoint to the dashboard page but isnt working:

 * @snippet       WooCommerce Add New Tab @ My Account
 * @how-to        Get FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 5.0
 * @donate $9
// ------------------
// 1. Register new endpoint (URL) for My Account page
// Note: Re-save Permalinks or it will give 404 error
function bbloomer_add_premium_support_endpoint() {
    add_rewrite_endpoint( 'premium-support', EP_ROOT | EP_PAGES );
add_action( 'init', 'bbloomer_add_premium_support_endpoint' );
// ------------------
// 2. Add new query var
function bbloomer_premium_support_query_vars( $vars ) {
    $vars[] = 'premium-support';
    return $vars;
add_filter( 'query_vars', 'bbloomer_premium_support_query_vars', 0 );
// ------------------
// 3. Insert the new endpoint into the My Account menu
function bbloomer_add_premium_support_link_my_account( $items ) {
    $items['premium-support'] = 'Premium Support';
    return $items;
add_filter( 'woocommerce_account_menu_items', 'bbloomer_add_premium_support_link_my_account' );
// ------------------
// 4. Add content to the new tab
function bbloomer_premium_support_content() {
   echo '<h3>Premium WooCommerce Support</h3><p>Welcome to the WooCommerce support area. As a premium customer, you can submit a ticket should you have any WooCommerce issues with your website, snippets or customization. <i>Please contact your theme/plugin developer for theme/plugin-related support.</i></p>';
   echo do_shortcode( ' /* your shortcode here */ ' );
add_action( 'woocommerce_account_premium-support_endpoint', 'bbloomer_premium_support_content' );
// Note: add_action must follow 'woocommerce_account_{your-endpoint-slug}_endpoint' format

But unfortunately isnt working… someone know why?

It seems to be related to WooCommerce account page, not the HivePress one. For HivePress, the easiest way is adding a new route Create a custom HivePress extension - Developer Docs You can add it via a custom extension (by creating a controller) or the hivepress/v1/routes filter hook.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.