Add Snippet To Project
Are you looking to customize your login page on your WordPress website? One simple way to make it more user-friendly and align it with your branding is to change the text from "Register" to "Sign Up." In this article, we’ll show you how to modify the register text on your login page, so you can create a seamless and cohesive user experience for your website visitors. Let’s dive in.
function wpturbo_change_register_text( $translated_text, $text, $domain ) {
if ( $text === 'Register' ) {
return __( 'Sign Up', 'wpturbo' );
}
return $translated_text;
}
add_filter( 'gettext', 'wpturbo_change_register_text', 10, 3 );
The code snippet provided tackles the task of changing the text "Register" to "Sign Up" on the login page of a WordPress website. This can be done by utilizing the WordPress gettext filter and creating a custom function called wpturbo_change_register_text()
.
When a translation is requested via the gettext filter, this function will be executed. The function takes three parameters: $translated_text
, $text
, and $domain
.
First, the function checks if the $text
parameter matches the string "Register". If it does, it uses the __()
function, which is a WordPress localization function, to translate and return the string "Sign Up".
If the $text
parameter is not "Register", the function simply returns the original $translated_text
.
The last part of the code is the crucial step in connecting our custom function with the correct filter. By using the add_filter()
function, we specify that the wpturbo_change_register_text()
function should be hooked into the gettext
filter with a priority of 10 and using 3 arguments.
With this code in place, whenever the login page is displayed with the "Register" text, it will be automatically replaced with "Sign Up". This can be customized further by modifying the translation string in the wpturbo_change_register_text()
function to match any desired text change on the login page.