[Resolved] Get Auto-generate Username on cred_save_data

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.

This topic contains 1 reply, has 2 voices.

Last updated by Waqar 5 months, 1 week ago.

Assigned support staff: Waqar.


Hi, I created a User Add form with Auto-generate Username. Then I need to get the Username on cred_save_data. I tried with
$user_login = $_POST['user_login'];, but it doesn't work.

can you help me?



Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Umberto,

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

Since the username is automatically generated, it is not available in the form's submitted data ($_POST).

To get it, you can use WordPress' "get_userdata" function.
( ref: https://developer.wordpress.org/reference/functions/get_userdata/ )


add_action('cred_save_data', 'user_form_data_action',10,2);
function user_form_data_action($post_id, $form_data)

	if ($form_data['id']==1234)
		$user_obj = get_userdata( $post_id );
		$usernanme = $user_obj->user_login;


Note: you'll replace "1234" with the ID of your actual form.

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