NB: Make sure you do a back up of your theme, files and database before attempting the tutorials
Last modified : Oct 14 2023
Estimated reading time : 1 minute, 41 seconds - 130 words
Share the post "MemberPress Subscriptions – WooCommerce customer account"
With this tutorial, we will add a new tab that will allow you to access MemberPress subs for each customer in their respective WooCommerce profiles.
We’re looking to add a new tab in the customer’s WooCommerce account.
//New Tab Woocommerce add_filter ( 'woocommerce_account_menu_items', 'subscriptions_woocommerce_link', 40 ); function subscriptions_woocommerce_link( $menu_links ){ $menu_links = array_slice( $menu_links, 0, 5, true ) + array( 'subscriptions' => 'Adhésions Memberpress' ) + array_slice( $menu_links, 5, NULL, true ); return $menu_links; } //Register permalink endpoint add_action( 'init', 'subscriptions_woocommerce_link_add_endpoint' ); function subscriptions_woocommerce_link_add_endpoint() { add_rewrite_endpoint( 'subscriptions', EP_PAGES ); } //Content for the new page in My Account, woocommerce_account_{ENDPOINT NAME}_endpoint add_action( 'woocommerce_account_subscriptions_endpoint', 'subscriptions_endpoint_content' ); function subscriptions_endpoint_content() { echo '<h2>Adhésions</h2>'; echo do_shortcode('[mepr-account-form]'); }
Once you’ve added the code in your functions.php file, you will need to go in your WordPress configurations and re-save your permalinks without changing the configurations.Simply click on Update.
Now, we will rewrite the display layout of the MemberPress template.
In order to proceed, you’ll need a WordPress theme or child theme. In the enabled theme, you’ll need to add a new MemberPress folder in the root folder of your theme and then add the mpca-manage-account-template.php file in the newly created folder.
You will also need the memberpress-corporate/app/views/mpca-manage-account-template.php file in the same MemberPress folder.