How7o
  • Home
  • Tools
  • Prank Screens
  • Contact
  • Blog
Reading: How to Add a Link or Button After the Login Form in WooCommerce
Share
Subscribe Now
How7oHow7o
Font ResizerAa
  • Marketing
  • OS
  • Features
  • Guide
  • Complaint
  • Advertise
Search
  • Home
  • Tools
  • Prank Screens
  • Contact
  • Blog
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.
How7o > Blog > Web Development > How to Add a Link or Button After the Login Form in WooCommerce
Web Development

How to Add a Link or Button After the Login Form in WooCommerce

how7o
By how7o
Last updated: May 10, 2026
6 Min Read
WooCommerce My Account login form hooks — five positions for injecting content
SHARE

To add a link, button, or shortcode output to the WooCommerce My Account login form, hook into woocommerce_login_form action points and echo your markup. The three most useful positions are woocommerce_login_form_start (top of form), woocommerce_login_form_end (bottom, typical choice), and the bracketing woocommerce_before_customer_login_form / woocommerce_after_customer_login_form that wrap the whole form block. This guide shows each and when to reach for which.

Contents
  • TL;DR
  • Hook positions on the My Account page
  • Injecting a shortcode
  • Custom HTML instead of a shortcode
  • Above the form or around the whole block
  • Where to put the code
  • Frequently asked questions
  • Related guides
  • References

Last verified: 2026-04-23 on WooCommerce 9.x with WordPress 6.5. Originally published 2023-06-24, rewritten and updated 2026-04-23.

TL;DR

add_action( 'woocommerce_login_form_end', 'how7o_add_social_login' );

function how7o_add_social_login() {
    echo do_shortcode( '[nextend_social_login]' );
}

Hook positions on the My Account page

  • woocommerce_before_customer_login_form — before the <form>, before any “Log in / Register” headings.
  • woocommerce_login_form_start — inside the form, before the username field.
  • woocommerce_login_form — inside the form, between the password field and the submit button.
  • woocommerce_login_form_end — inside the form, after the submit button. The most common slot.
  • woocommerce_after_customer_login_form — after the form (and registration form, if shown).

Pick the position that matches your UX — social-login buttons typically sit below the native form (use woocommerce_login_form_end), a Terms notice typically sits above (use woocommerce_login_form_start).

Injecting a shortcode

add_action( 'woocommerce_login_form_end', 'how7o_add_social_login' );

function how7o_add_social_login() {
    echo do_shortcode( '[nextend_social_login]' );
}

If a plugin (Nextend Social Login, Super Socializer, etc.) provides a shortcode for its button group, do_shortcode() renders it at the hook point. No template overrides needed, no child-theme copying of WooCommerce files.

woocommerce login form hook — five positions around the My Account login form

Custom HTML instead of a shortcode

add_action( 'woocommerce_login_form_end', 'how7o_add_password_reset_link' );

function how7o_add_password_reset_link() {
    printf(
        '<p class="woocommerce-lost-password"><a href="%s">%s</a></p>',
        esc_url( wp_lostpassword_url() ),
        esc_html__( 'Forgot your password?', 'how7o' )
    );
}

When you don’t have a shortcode — a custom link, a compliance notice, a call-to-action for a specific flow — echo the HTML directly. Use esc_url and esc_html on any dynamic parts so the output is safe against XSS if values ever come from translation strings or options.

Above the form or around the whole block

// Before the login form
add_action( 'woocommerce_before_customer_login_form', function () {
    echo '<div class="notice">Accounts created before 2024 require a password reset.</div>';
} );

// After the login form (and registration, if shown)
add_action( 'woocommerce_after_customer_login_form', function () {
    echo '<p class="small">By signing in you agree to our <a href="/terms">terms</a>.</p>';
} );

The before_customer_login_form / after_customer_login_form pair wrap the whole form block and don’t inject inside the <form> tag, so they’re fine for global notices, terms links, or marketing content.

Where to put the code

Child theme’s functions.php — not the parent theme. Parent themes get wiped on update and you lose the customization. If you don’t have a child theme yet, create one with:

/* wp-content/themes/parent-child/style.css */
/*
Theme Name: Parent Child
Template:   parent
*/

And an empty functions.php in the same folder. Activate the child theme in Appearance → Themes and paste your add_action calls there.

Frequently asked questions

What’s the simplest woocommerce login form hook?

woocommerce_login_form_end — fires right before the closing </form> of the WooCommerce login form on the My Account page. Echo whatever you want to inject there. The sibling hook woocommerce_login_form_start fires at the top of the form, and woocommerce_before_customer_login_form / woocommerce_after_customer_login_form bracket the whole form block (including the registration form if it’s shown).

Should I use add_action or add_filter?

add_action — woocommerce_login_form_end is an action, not a filter. The source post uses add_filter, which works because WooCommerce calls do_action under the hood and both action and filter registrations accept the same callback signature. Still, add_action is the correct form and communicates intent better.

Can I add any HTML, not just a shortcode?

Yes — anything you echo inside the callback renders inline where the hook fires. Common uses: a social-login button from a plugin shortcode, a link to the password-reset page, a Terms link, a styled Google/Facebook sign-in button you built yourself. The only constraint is that the HTML is injected inside the <form> tag, so avoid nested <form> elements.

Will this also show on the registration form?

woocommerce_login_form_end is scoped to the login form only. For the registration form, use woocommerce_register_form_end with the same shape. To inject into both at once, hook woocommerce_after_customer_login_form — it fires after both forms on the My Account page.

Do I need the child-theme functions.php?

Always put WooCommerce customizations in a child theme (or a site-specific plugin) — never the parent. Parent themes get overwritten on update and you lose everything. If you don’t have a child theme yet, creating one is two files: style.css with the right Template: header and an empty functions.php.

Related guides

  • How to Display Orders Instead of Dashboard on the WooCommerce My Account Page — another My Account customization.
  • How to Remove Checkout Fields in WooCommerce — same pattern of filter-based WooCommerce tweaks.
  • How to Login a User Programmatically in WordPress — what happens when SSO provider returns.
  • How to Display Different Menus to Logged-In Users in WordPress — related post-login UI change.

References

WooCommerce hook reference: woocommerce.com/document/introduction-to-hooks-actions-and-filters.

TAGGED:phpWooCommercewordpress

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article WordPress admin notice — four notice types shown at the top of the admin area How to Show Custom Notifications in the WordPress Dashboard
Next Article WooCommerce add custom fee — woocommerce_cart_calculate_fees + WC()->cart->add_fee How to Add a Custom Fee (or Transaction Fee) in WooCommerce
Leave a Comment

Leave a Reply Cancel reply

You must be logged in to post a comment.

FacebookLike
XFollow
PinterestPin
InstagramFollow

Subscribe Now

Subscribe to our newsletter to get our newest articles instantly!
Most Popular
Display PHP errors — ini_set + php.ini configuration
How to Display PHP Errors
May 10, 2026
PHP convert string to uppercase — strtoupper and mb_strtoupper
How to Convert a String to Uppercase in PHP
May 10, 2026
PHP string to float conversion with cast, regex cleanup, NumberFormatter
How to Convert a String to Float in PHP
May 10, 2026
PHP merge arrays without duplicates — union operator and array_unique
How to Combine Two Arrays Without Duplicates in PHP
May 10, 2026
PHP delete array element — unset, array_splice, array_filter, array_search
How to Delete an Element from a PHP Array
May 10, 2026

You Might Also Like

WordPress order posts by meta value — WP_Query or pre_get_posts with meta_value_num
Web Development

How to Order Posts by Meta Value in WordPress

8 Min Read
Install PHP on Ubuntu — terminal with apt install php command and stylized elephant icon
Web Development

How to Install PHP on Ubuntu (22.04 & 24.04): Step-by-Step Guide

9 Min Read
WordPress prepare LIKE SQL — %s placeholder + % wildcards in the value
Web Development

How to Prepare a %LIKE% SQL Statement in WordPress

7 Min Read
Replace Broken Images Automatically with JavaScript
Web Development

Replace Broken Images Automatically with JavaScript (and jQuery)

5 Min Read
How7o

We provide tips, tricks, and advice for improving websites and doing better search.

Latest News

  • SEO Audit Tool
  • Client ReferralsNew
  • Execution of SEO
  • Reporting Tool

Resouce

  • Google Search Console
  • Google Keyword Planner
  • Google OptimiseHot
  • SEO Spider

Get the Top 10 in Search!

Looking for a trustworthy service to optimize the company website?
Request a Quote
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?