Skip Navigation

[Resolved] how do I capture current logged in userid using hidden field

This support ticket is created 3 years, 1 month 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 2 replies, has 2 voices.

Last updated by leoH-2 3 years, 1 month ago.

Assisted by: Waqar.

Author
Posts
#2198023
Screenshot 2021-10-17 at 12.41.30 PM.png
Screenshot 2021-10-17 at 12.41.43 PM.png
Screenshot 2021-10-17 at 12.34.56 PM.png

I am trying to capture logged in user info, his userid, using a hidden field in Toolset form and saved it as custom fields for CPT.
I have a custom post type name: Diver sizing and custom fields group assign to this CPT.

I want a Logged in user to be able to submit a form for equipment sizes. So I need userid to be captured in the form. I have put custom field-slug in the hidden field slug and in the value I have put shortcode [wpv-user field="ID"].

When I test this out, it is not captured. and another issue I have is that everytime the form is submitted, the CPT post saved but with blank on the userid and the post title become CREDAutodraftxxxxxxxxx.

1. How do I pass the value from hidden field in the form to custom field.
2. How Do I use the hidden field as the post title when user submit the form.

Thank you for your kind assistance.

#2198637

Hi,

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

Your approach of using the "wpv-user" shortcode to pass on the current user's ID is correct and should work.

To troubleshoot and suggest the best way to achieve both these points, I'll need to see how this form is set up in the admin area.

Can you please share temporary admin login details along with the link to the page with this form?

Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.

regards,
Waqar

#2198859

Hi Waqar.

My issue is resolved now. Thank you!

I realized that if the field is hidden especially for the post title the value will not be recorded.

So i found a workaround by using CSS to hide the custom field that initially using hidden form field and place the wpf-user info as default value. And when i test this solution when form is submitted by user, all the data is captured into CPT.

Thanks