Skip Navigation

[Resolved] I would like insert user data in a post form when I open it

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: Africa/Casablanca (GMT+01:00)

This topic contains 5 replies, has 2 voices.

Last updated by andreaP-10 3 years, 1 month ago.

Assisted by: Jamal.

Author
Posts
#2177945
screenshot02.JPG
screenshot03.JPG
screenshot01.JPG

Hi there,
I created a custom post type named "ticket" using toolset, to collect, filter and show the assistance tickets for the logged-in users
I also created a custom fields group named "campi ticket" related to mentioned custom post type in witch I added two fields named "ID utente" and "data apertura" to filter the tickets and to order them in the user reserved area
Finally, I created a post form to insert a new ticket and I put it in a page with access restricted for only the logged-in users
When the user open this page I would like automatically insert in "ID utente" and "data apertura" fields the logged-in userID and the current date, making them unavailabale for the user
Is it possible? and if it is, how can I do this?
Furthemore:
How can I show the custom taxonomy as a dropdown list? (I only able to add them manually)
How can I stylize the calendar icon and the trash icon in the post form? (I added a custom CSS for other fields but I can't stylize them)
Thank you very much

#2178655

Hello and thank you for contacting Toolset support.

I am afraid, I am still confused about what you want to achieve. From the screenshots, the form is for creating a new "Ticket" post. However, the form's screenshot displays the fields of the Repeatable Field Group(RFG) "campi ticket". So, I wonder if you want to add an RFG item when creating a new Ticket? Or does the form create RFGs items instead of the Ticket post?

If it is the first case, I am afraid, you will need to add the data using Javascript. It can't be added using Toolset settings, or PHP code.

To better assist you, I'd like to take a closer look at your website. See how the form is built and how it is being used on the frontend. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **

#2178827

My apologies, I misunderstood the custom field group as an RFG.

Regarding the default value for the date field, you need to pass a valid timestamp instead of a string. For example, assuming the current_date shortcode is registered:

[cred_field field='data-evento' force_type='field' class='form-control' output='bootstrap' value='[current_date format='U']']

https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_field

Regarding the select field for taxonomy, that is available only for Hierarchical taxonomies. In that case, you will need to switch to the expert editing mode and add the following attributes to the taxonomy field shortcode ... display="select" single_select="true"]

[cred_field field='categoria-ticket' force_type='taxonomy' output='bootstrap' class='form-control' display="select" single_select="true"]

https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_field

The calendar image can be customized with the jQuery UI datepicker API. You will need to apply the image option for it, or hide the image.
hidden link

The Trash icon is provided by Toolset. You will need custom CSS. Let me know what you want to achieve and I'll do my best to help.

Regarding making the ID and date fields read-only. It can't be done without some custom Javascript code. And for the date field, I don't think jQuery UI Datepicker has a read-only mode.

This being said, I wonder why would you display these fields in the form if you want to set default values for them without letting the user change them. Why not using a custom code snippet, hooked to the cred_save_data action, and programmatically set these values?
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

I would like to hear from you about it. Why would you want to make these fields read-only, instead of completely hiding them or programmatically assign them?

#2178859

I didn't know I able to enter values ​​without showing the field. I am an absolute beginner
Thanks for your your precious suggestion
I try to complete the setup as you indicated me and in case of need I'll return to you
Thank you

#2179375

You are very welcome. I am setting this ticket as waiting for your reply which should keep it open for a couple of weeks. You should receive reminder notifications before it gets closed.

#2180185

If I'll find some difficulty in the process I'll come back to you.
For the moment my issue is resolved. Thank you!