Skip Navigation

[Resolved] Password template

This support ticket is created 2 years, 6 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 2 years, 6 months ago.

Assisted by: Waqar.

Author
Posts
#2362471

Hi, using the Toolset User Form and "Automatically create password/username", there's a way to establish the password/username structure before it is submitted?
I would need this to be something like

firstname_lastname
pass+userid

Thanks

#2362707

Hi,

Thank you for contacting us and I'd be happy to assist.

I'm afraid, there is no built-in feature or function available to set a specific format for the automatically generated usernames and passwords.

One workaround that you can use for setting a username consisting of the first and last name, is to disable the option "Auto-generate Username" so that there is a field in the form to enter it.

Next, in the form's "JS editor", you can include the following custom script, which can automatically fill the username value in its field, in the "firstname_lastname" format, as a user makes changes in the first and last name field values, in their respective fields.


jQuery(document).ready(function( $ ) {
	
	// get the values from the first and last name fields and fill them in the username field
	$.fn.setAutoUsername = function(){
		$("input[name=user_login]").val($("input[name=first_name]").val()+'_'+$("input[name=last_name] ").val());
	}
	
	// detect change in the first name and last name field and execute function 'setAutoUsername'
	$("input[name=first_name], input[name=last_name] ").change(function(){
		$.fn.setAutoUsername();
	});
	
});

You can hide the username field using custom CSS code so that users can't actually see it and make any changes.

Setting a password in any specific format is more challenging and it makes a little sense, as it can be changed by the user, later.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar