Skip Navigation

[Resolved] update a single fields without opening full edit form

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

Problem:

After submit Toolset form for editing post, customize the redirected URL.

Solution:

You can try filter hook "cred_success_redirect", for example:

https://toolset.com/forums/topic/update-a-single-fields-without-opening-full-edit-form/#post-1284729

Relevant Documentation:

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

This support ticket is created 5 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/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by mikeB-14 5 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#1283999
updatefield.JPG

Hi
I have a view which list delegates who are booked in for training
I have to try to get 2 things done.
1. I would like to update the email request field without having to click the edit delegate link to the form to open it and update the field.... Just takes too long

Ideally, I would like to click on the email request field (which is a checkbox) and the system will update that row.

2. The Take Survey link is a URL to SurveyMonkey with the details of the delegate in the url.
I would like some way of updating a custom field (eg. On site Survey checkbox), which gets ticked first and then fires off to url page of the survey.

Delegate View List

<td>[types field="first-name"][/types]</td>
<td>[types field="last-name"][/types]</td>
<td>[types field="delegate-email" output='raw'][/types]</td>
<td>[types field='email-request' state="checked"]Yes[/types][types field='email-request' state="unchecked"]No[/types]</td>

<!-- I don't think we need to delete delegates
<td>[cred_delete_post_link action='delete' text='Delete %TITLE%' message='Are you sure you want to delete this delegate?' message_show='1' class='cred-refresh-after-delete']</td>
-->
[wpv-conditional if="( $(wpcf-email-request) ne '1' )"]

<td>hidden link field='first-name' ][/types] [types field='last-name'][/types]&crn=[types field='task' item='@delegate-group.parent'][/types] &cd=[types field='stdstartdate' item='@delegate-group.parent'][/types]&ct=[types field='employee' item='@delegate-group.parent'][/types]&cln=[types field='clientname' item='@delegate-group.parent'][/types]&cidn=[types field='idx_chantier' item='@delegate-group.parent'][/types]&de=
[types field='delegate-email' output='raw'][/types]">Take Survey

</td>
[/wpv-conditional]

<td>[toolset-edit-post-link content_template_slug='planner-unassigned' target='self']Edit %%POST_TITLE%%[/toolset-edit-post-link]</td>

----------------------------------------------------------------
Edit Delegate form

<div>hidden link;">Back to Delegate List</div>

[credform]
[cred_field field='form_messages' class='alert alert-warning']

<div class="form-group">
<label>First Name</label>
[cred_field field='first-name' force_type='field' class='form-control' output='bootstrap']
</div>
<div class="form-group">
<label>Last Name</label>
[cred_field field='last-name' force_type='field' class='form-control' output='bootstrap']
</div>
<div class="form-group">
<label>Delegate Email</label>
[cred_field field='delegate-email' force_type='field' class='form-control' output='bootstrap']
</div>
<div class="form-group">
<label>Email Request</label>
[cred_field field='email-request' force_type='field' class='form-control' output='bootstrap']
</div>
<div class="form-group hidden">
<label>Planner Event</label>
[cred_field field='@delegate-group.parent' class='form-control' output='bootstrap' select_text='--- not set ---']
</div>
[cred_field field='form_submit' output='bootstrap' value='Update' class='btn btn-primary btn-lg']

[/credform]

#1284429

Hello,

Q1) There isn't such kind of built-in feature within Toolset plugins, one Toolset post form can handle only one post at same time.
In your case, if you are familiar with custom PHP/JS codes, you can consider these:
1) When user click the the email request field "Yes/No" text, trigger a AJAX call:
https://codex.wordpress.org/AJAX_in_Plugins

2) In server side, update the custom field "email request" field value to what you want.
https://codex.wordpress.org/Function_Reference/update_post_meta

Q2) Please elaborate the questions with more details:
How and when do you want to update a custom field?
How and where do you want to tick first and then fires off to url page of the survey?

Please provide detail steps to duplicate the same problem, I need to test it in my localhost, thanks

#1284649

Q2

I think the best way for me to do this would be to have a custom checkbox field called eg. (take_survey).
Then have a button which when clicked would run a code snippet to do 2 things
1. Update the take_survey field to 1
2. Then the open up a url with parameters.

That URL already works, it's just getting the value set on take_survey field before it opens the URL page.

I think that could be done via a button method

What do you think?

Tony

#1284729

I assume we are talking about a Toolset form for editing post.

If it is, yes, it is possible, after user submit the form, you can use filter hook "cred_success_redirect" to trigger a PHP function:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

In this PHP function, do these:
Get the take_survey field value and Add it as the URL parameter:
https://developer.wordpress.org/reference/functions/get_post_meta/

For your reference.

#1284841

So I am going to close the call.
I will make sure I create a edit post form which will only have take survey button so it fits on my view row layout and look at creatng a code snippet to do the submit and the redirect url page
Thanks
Tony