Skip to content

Instantly share code, notes, and snippets.

@hirejordansmith
Created February 20, 2018 16:26
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 hirejordansmith/6e19528dd77a1585d92c46c7ac3b4390 to your computer and use it in GitHub Desktop.
Save hirejordansmith/6e19528dd77a1585d92c46c7ac3b4390 to your computer and use it in GitHub Desktop.
Add New Tab to the WooCommerce My Account Page
/**
* @snippet Add New Tab to WooCommerce My Account Page
* @author Hire Jordan Smith // https://hirejordansmith.com
*/
// Register new endpoint to use for My Account page
add_action( 'init', 'hjs_add_account_update_endpoint' );
function hjs_add_account_update_endpoint() {
add_rewrite_endpoint( 'account-update', EP_ROOT | EP_PAGES );
}
// Add new query var
add_filter( 'query_vars', 'hjs_account_update_query_vars', 0 );
function hjs_account_update_query_vars( $vars ) {
$vars[] = 'account-update';
return $vars;
}
// Insert the new endpoint into the My Account menu
add_filter( 'woocommerce_account_menu_items', 'hjs_add_account_update_link_my_account' );
function hjs_add_account_update_link_my_account( $items ) {
$items['account-update'] = 'Account Details';
return $items;
}
// Add content to the new endpoint
add_action( 'woocommerce_account_account-update_endpoint', 'hjs_account_update_content' );
function hjs_account_update_content() {
echo '<h3>Account Details</h3>';
echo do_shortcode('[gravityform id="3" title="false" description="false" ajax="true" tabindex="-1"]');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment