Problem: I would like to use a CRED form to save the current page URL into a custom field on a new post. I plan to use this as a "saved search" so Users can visit the same search again later.
Solution: If your form does not use AJAX, you can use the following code to automatically save the current page URL in a CRED custom field:
add_action('cred_save_data', 'save_page_url_to_custom_field',10,2); function save_page_url_to_custom_field($post_id, $form_data) { if ($form_data['id'] == 123) { update_post_meta($post_id, 'wpcf-search-url', $_SERVER['HTTP_REFERER']); } }
Replace '123' with the numeric ID of this CRED form, and replace "search-url" with the slug of your custom field.
Relevant Documentation: https://toolset.com/documentation/programmer-reference/cred-api/#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.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 4 replies, has 2 voices.
Last updated by 6 years, 11 months ago.
Assisted by: Christian Cox.