Translate Registration Fields & Options

Hi there,

i still have problems with translation my website. The registration form is the problem. I added several registration fields in s2member but have problems to translate them in different languages. I use the s2Member-Pro-Stripe-Form register=“1” to show the registration process.

I learned that the problem is, that the labels and options are used in plain text and doesn’t get localized. I found a very helpful thread: https://www.s2member.com/forums/topic/translation-of-custom-registration-fields/index.html

The trick is to hook in the registration process and replace the labels with localized labels. But still i have no success in doing so.

I added the following to my theme’s functions.php:

add_action("ws_plugin__s2member_during_configure_user_registration", "translate_custom_field");
add_action("ws_plugin__s2member_during_profile_during_fields_during_custom_fields_before", "translate_custom_field"); 

function translate_custom_field($rec)
{
// labels
$label = $rec['field']['label'];
$rec['field']['label'] = 'test';

$label = $rec['field']['sectitle'];
$rec['field']['sectitle'] = 'test';

return $rec;
}

The idea is that every label and sectitle should be ‘test’ after that. But nothing changed.

What am i missing? Do i need anything else to make the hook work? Obviously the translate_custom_field-function is never executed.

Hope that anybody has an idea for me.

First off, I cannot verify the action hooks to know if they are correct. To test if I have the right hook, I might throw an exit("CustomMessage..."); somewhere in your function to see if it is actually firing. If the page loads normally, keep looking for new hooks to try.

If the function is firing, then I would adjust the priority of your action. See Add_Action Function Reference Docs.

I might give it a priority of 9999 or higher to test, but lower the number to something more reasonable that still works. (This is worth testing in case your function is running before a different function that sets the actual labels/titiles.)

Hope these ideas help.

~Cam

Thanks for your idea.

I gave up actually… I just edited the s2member code myself to add translation to the custom registration fields. Works but is not the perfect solution.

Well translation into another Language is simple, but several languages - e.g English and German I haven’t found out how to do it. So everything is like : English-German - i.e. pay now - Jetzt bezahlen on the checkout button

For clarification: I did not use the translation per se, but made the s2member fields translatable. The translation can then be done as usual with the tool of choice in the Wordpress backend (in my case with Loco Translate).

Well maybe you can offer a diff file or patch with this here or on GitHub of S2 member. Not sure how it would work together with qtranslate xt that I’m using. I need fields to enter the language shortcodes…

And what about emails?