Skip Navigation

[Resolved] How do I capture the user submitting a Toolset form?

This thread is resolved. Here is a description of the problem and solution.

Problem:

How do I capture the username for the user that is submitting a form?

Solution:

If you are going to capture the username with PHP codes, you can try Form API action hook "cred_save_data":

https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

The first argument is user's ID, then use user's ID to get username, for example:

https://toolset.com/forums/topic/how-do-i-capture-the-user-submitting-a-toolset-form/#post-1280569

Relevant Documentation:

This support ticket is created 5 years, 4 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by Gerard 5 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1280509

How do I capture the username for the user that is submitting a form?

#1280515

Having a chat about it on the facebook group at hidden link

#1280569

Hello,

Please elaborate the question with more details.
How do you setup the user form? is it a creating new user form? are you using option "Auto-generate Username"?
How and where do you want to capture the username?

If you are going to capture the username with PHP codes, you can try Form API action hook "cred_save_data":
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

The first argument is user's ID, then use user's ID to get username, for example:

add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($user_id, $form_data)
{
    // if a specific form
    if ($form_data['id']==123)
    {
        $user_obj = get_user_by('id', $user_id);
        $user_name = $user_obj->user_login;
    }
}

More help:
https://developer.wordpress.org/reference/functions/get_user_by/

#1282385

Hi,

Thank you, that seems very useful..

Let me share some more details, and maybe you can recommend the best way to go about things.

What I'm building is a site to manage the data on people who have received grants..
- There will be a profile for each grantee
- They will have logins to regularly come in and put in a status report
- The profile and accounts will be created by the website managers
- These status reports will display on their profile in a section, using Views probably.

I'm trying to figure out the best way to keep these all linked together properly.

I hope this makes more sense?

New threads created by Luo Yang and linked to this one are listed below:

https://toolset.com/forums/topic/recommend-the-best-way-to-go-about-things/

#1282479

I assume the original question of this thread is resolved, for other new questions, please check the new thread here:
https://toolset.com/forums/topic/recommend-the-best-way-to-go-about-things/

#1282483

My issue is resolved now. Thank you!