0

I've been trying to get this to work on my account pages, wanted to add a "Membership" tab under my accounts page for WooCommerce, but when i click on the custom tabs I created, it shows a "page does not exist error message" as such.

Current Usser Output

This is what it looks like on the my-account page. Basically wanted the custom content to display when user click onto the custom tab, like the following. This is just an example for My Orders Tab.

enter image description here

Any Idea what could have gone wrong here? I am using the following action hooks to create the custom tab. Code added to my "functions.php" file of my child theme.

  
function bbloomer_add_custom_endpoint() {
    add_rewrite_endpoint( 'membership', EP_ROOT | EP_PAGES );
}
  
add_action( 'init', 'bbloomer_add_custom_endpoint' );
  
  
  
function bbloomer_membership_query_vars( $vars ) {
    $vars[] = 'membership';
    return $vars;
}
  
add_filter( 'query_vars', 'bbloomer_membership_query_vars', 0 );
  
  
function bbloomer_add_membership_link_my_account( $items ) {
    $items['membership'] = 'Membership';
    return $items;
}
  
add_filter( 'woocommerce_account_menu_items', 'bbloomer_add_membership_link_my_account' );
  
  
function bbloomer_membership_content() {
    echo '<h3>Membership Custom Tab </h3><p>Welcome to the Membership area.</p>';
    //echo do_shortcode( ' /* your shortcode here */ ' );
}
  
add_action( 'woocommerce_account_membership_endpoint', 'bbloomer_membership_content' );

Credit to @Dario Ferrer answer code from 2016-06-27 that inspired Business Bloomer code

And I dont think adding a seperate page such as "https://mydomain/my-account/membership/" would help with this too.

LoicTheAztec
  • 229,944
  • 23
  • 356
  • 399
  • you haven't pasted the code that builds this links (view, invoice) on that tab? I guess somewhere you have memebership ID's specific for each user, and that peace of code that builds that loop is not reffering to correct urls and you end up with 404 – Kresimir Pendic Jul 10 '20 at 05:40
  • Take care when you add credits from somewhere else picked code, they are often copied or inspired (partially) from existing StackOverFlow *(without mentioning their sources)*. – LoicTheAztec Jul 10 '20 at 07:43
  • **Important to make it work:** Once you have saved that code, ***"go to Dashboard > Settings > Permalinks and click "Save Settings" in order to flush rewrite rules"*** – LoicTheAztec Jul 10 '20 at 08:00
  • Hi @Kresimir Pendic, yeah I noticed that too. I refered to the revised solution provided by LoicTheAztec, and I missed out a few thing from the code which I have shown earlier. Anyways thanks for the solution LoicTheAztec ! Noted on the credits for future posts too. – wjyeshealth Jul 10 '20 at 13:07

0 Answers0