Search code examples
phpwordpresswoocommerceuser-registrationhook-woocommerce

Add a custom text in WooCommerce login page


In WooCommerce login page, I need to add a statement "Not a user? register now" under the login form next to "lost your password?" to let the unregistered user go easily to the registration page when pressing on this statement.

So, how can I add it?

Thanks.


Solution

  • Use this custom function hooked in woocommerce_after_customer_login_form action hook this way:

    add_action( 'woocommerce_after_customer_login_form', 'custom_login_text' );
    function custom_login_text() {
        if( ! is_user_logged_in() ){
            //Your link
            $link = home_url( '/register' );
    
            // The displayed (output)
            echo '<p>'. __("Not a user? <a href='$link'>register now<a/>", "woocommerce").'</p>';
        }
    }
    

    Code goes in function.php file of your active child theme (or theme) or also in any plugin file.

    The code is tested and works.