Skip Navigation

[Resolved] Translate and edit login forms

This support ticket is created 7 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 4 replies, has 2 voices.

Last updated by romanB-3 7 years, 7 months ago.

Assisted by: Nigel.

Author
Posts
#488553

Hello,
I want to edit the content of the login default forms, in order to add placeholders and texts for instance.
I also need to translate those forms, and the mail sent to the user after password reset.
How may I do that ?
Is there a way to do it without loosing this after update ?
Thank you.

#488580

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Roman

The documentation for the login form shortcode is here: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-login-form

The shortcode just mimics the output of the standard WordPress login form and doesn't provide any attributes for customisation, other than the urls to redirect to on success or failure.

There is no way to add placeholder text, for example.

However, if you are willing to write some PHP, there is scope to add additional content to the form.

Probably the best way to see what is possible is to look at the source code used to generate the form. In the file wp-content/plugins/wp-views/embedded/inc/wpv-shortcodes.php look for the definition for function wpv_login_form (line 697 in the current version).

You will see there is a filter 'login_form_defaults' you can use to change the form texts.

Then there are filters 'login_form_top', 'login_form_middle', and 'login_form_bottom' where you can insert additional HTML into the form.

We currently have internal tickets for issues where the login form texts have not been correctly registered for translation, and cannot be translated. There are some deeper challenges here which mean that this work is actually ongoing and I'm not sure when it will be fixed.

In the meantime, you can use that 'login_form_defaults' filter to modify the form labels, including providing them in an alternate language.

I'm sorry if the reply implies more work than you were hoping for.

#488618

hello and thank you very much,
I just have one more question : by editing the php, I will lose these edits when update.
I could I avoid losing the edit ?
Thanki you.

#488626

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Roman

You don't need to edit the source files.

Instead you add code to your theme's functions.php file (or using a plugin such as Code Snippets) which "hooks" into the source code where you want to make changes.

You can read about WordPress filters here: https://developer.wordpress.org/plugins/hooks/filters/

You should be able to insert some content at the top of the login form with some code like the following:

function custom_login_form_top( ){

    $output = "<h2>My custom login form</h2>";

    return $output;
}
add_filter( 'login_form_top', 'custom_login_form_top' );

These filters are a little different as the filter customarily passes a variable to your custom function which modifies the variable and returns it. In this case you simply need to return a string of what you want to add to the form.

#489463

It seems a lot more complicated to user filters thank to edit the php file...
If there is no simple other way, I will copy the file after each update...
Thank you.

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.