How7o
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Reading: How to Add a Link or Button After the Login Form in WooCommerce
Share
How7oHow7o
Font ResizerAa
  • OS
Search
  • Home
  • Tools
  • Prank Screens
  • Learn
  • Blog
  • Contact
Follow US
© 2024–2026 How7o. All rights reserved.
How7o > Free Laravel, PHP, WordPress & Server Tutorials > 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.
[mc4wp_form]
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
Most Popular
Set vi as the default editor in Ubuntu — a terminal opening the vim editor
How to Set vi (Vim) as the Default Editor in Ubuntu
June 8, 2026
rsync says ALL DONE but files are missing — a terminal showing ALL DONE next to an empty folder
rsync Says “ALL DONE” but Files Are Missing: How to Verify
June 8, 2026
Migrate a website to a new server with rsync — files copying from an old server to a new one over SSH
How to Migrate a Website to a New Server With rsync
June 8, 2026
Bun runtime — faster JS toolkit replacing npm in Laravel projects
How to Install Bun Runtime on Ubuntu (And Use It in a Laravel Project)
May 24, 2026
Tailscale mesh — peer-to-peer connections between devices, coordination server
How to Install Tailscale on Ubuntu (Zero-Config Mesh VPN for Self-Hosters)
May 24, 2026

You Might Also Like

MySQL extract digits from string — REGEXP_REPLACE negation class
Web Development

How to Extract Only the Digits from a String in MySQL

6 Min Read
Fix CORS policy blocked origin errors in PHP and Apache
Web Development

How to Fix “CORS Policy Blocked Origin” Errors

5 Min Read
Laravel Blade Time Format (HH:MM)
Web Development

How to Show Only Hours and Minutes in Laravel Blade (HH:MM)

3 Min Read
Set and get cookies with JavaScript
Web Development

How to Set and Get Cookies with JavaScript

6 Min Read
How7o

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

Tools

  • Age Calculator
  • Word Counter
  • Image Upscaler
  • Password Generator
  • QR Code Generator
  • See all tools→

Pranks

  • Fake Blue Screen Prank
  • Hacker Typer
  • Fake iMessage Generator
  • Windows XP Crash Prank
  • Windows 11 Update Prank
  • See all prank screens →

Company

  • About Us
  • Blog
  • Contact
  • Privacy Policy
  • Terms of Service
  • Sitemap
© 2024–2026 How7o. All rights reserved.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?