write a plugin to customise woocommerce my-account page

Home » Snippets » write a plugin to customise woocommerce my-account page

Created with:



Creator: SmartOps

Customize with WPTurbo AI

Add Snippet To Project

New Project
Add To Existing Project
 * Plugin Name: Custom My Account
 * Description: Customizes the WooCommerce My Account page.
 * Version: 1.0
 * Author: Your Name
 * Author URI: Your Website
 * Text Domain: custom-my-account

// Add a custom endpoint to the My Account page
function custom_my_account_endpoint() {
    add_rewrite_endpoint( 'custom-page', EP_ROOT | EP_PAGES );
add_action( 'init', 'custom_my_account_endpoint' );

// Add a new tab to the My Account navigation menu
function custom_my_account_navigation( $items ) {
    $items['custom-page'] = 'Custom Page';
    return $items;
add_filter( 'woocommerce_account_menu_items', 'custom_my_account_navigation' );

// Display content for the custom endpoint
function custom_my_account_content() {
    echo '<h2>' . __( 'Custom Page', 'custom-my-account' ) . '</h2>';
    echo '<p>' . __( 'This is a custom page added to the My Account section.', 'custom-my-account' ) . '</p>';
add_action( 'woocommerce_account_custom-page_endpoint', 'custom_my_account_content' );


To use this code, create a new file named "custom-my-account.php" in your WordPress plugins directory. Copy and paste the above code into that file. Then, activate the "Custom My Account" plugin through the WordPress admin dashboard.

After activating the plugin, you'll see a new tab called "Custom Page" on the WooCommerce My Account page. When clicked, it will display the custom content defined in the custom_my_account_content() function.

Feel free to modify the content and styling of the custom page to suit your needs.

Register an account to save your snippets or go Pro to get more features.