• Add-ons
  • Blog
  • Resources
    • Documentation
    • FAQs
    • Code snippets
    • Use cases
    • Support
  • Account
    • My account
    • Checkout
    • Cart
  • English
  • French
  • Add-ons
  • Blog
  • Resources
    • Documentation
    • FAQs
    • Code snippets
    • Use cases
    • Support
  • Account
    • My account
    • Checkout
    • Cart
  • English
  • French
home/Knowledge Base/Code snippets/Authentication Forms: change the links below the forms

Authentication Forms: change the links below the forms

171 views 0 April 13, 2021

You may want to change the registration, login or forgot password links that can be seen below the form. This can be done using hooks in your theme’s functions.php file.

The simple way

If you just need to change the URL of the link, you can simply use a hook like this:

function cuar_change_login_link($original_url, $redirect_to) {
  return 'http://example.com/my-custom-login-page';
}
add_filter('cuar/authentication-forms/form-url?action=login', 'cuar_change_login_link', 10, 2);

function cuar_change_register_link($original_url) {
  return 'http://example.com/my-custom-register-page';
}
add_filter('cuar/authentication-forms/form-url?action=register', 'cuar_change_login_link', 10, 2);

// And so on with other hooks:
// 'cuar/authentication-forms/form-url?action=forgot-password'
// 'cuar/authentication-forms/form-url?action=reset-password'
// 'cuar/authentication-forms/form-url?action=logout'

A more advanced solution

If you need more flexibility – to change the texts, add more links, etc. – you can use the snippet below:

function cuar_change_auth_links($links, $current_form_id) {
  // Here is how we could change the target of the register link
  if (isset($links['register'])) {
    $links['register'] = sprintf( '%2$s',
      esc_attr('http://example.com/my-custom-registration-form'), 
      esc_html(__('Create your account', 'cuarlf'))
    );
  }

  // Here is how we could remove the forgot password link
  unset($links['forgot-password']);

  // Here is how we can add a custom link
  $links['tos'] = sprintf( '%2$s',
    esc_attr('http://example.com/terms-of-service'), 
    esc_html(__('Terms of service', 'yourdomain'))
  );

  return $links;
}
add_filter('cuar/authentication-forms/form-links', 'cuar_change_auth_links', 10, 2);

In this case, it is always a good idea to also use the simple snippets to update the URLs too.

Tags:authentication forms

Was this helpful?

Yes  No
Related Articles
  • Custom admin notification’s recipients
  • Disable CSS resets and allow integration of third party plugins
  • Automatically add a user to a group
  • Changing the default page shown by the Customer Area
  • Changing the page shown after logout
  • Sidebars: how to disable them
Knowledge base
  • Code snippets 25
  • Use cases 2
  • Community links 5
FAQ
  • About licences 7
  • Pre-sales questions 3
  • After-sales questions 1
  • Plugin usage 8
  • Technical questions 10
  • Payments 4
Documentations
  • Getting started
  • Using code snippets
  • The template system
  • Full documentation
Support
  • Pre-sales Enquiries
  • Main plugin support
  • Premium add-ons support
  • Feature Requests
  • Terms and conditions for sales
  • Refund policy
  • Privacy Policy
  • Legal notices
  • Copyright 2021 wp-customerarea.com. All Rights Reserved.