Problem: I have set up a custom form where my site users can select multiple posts. When the form is submitted, the page URL is updated to include those selected post IDs in a repeating URL parameter post_ids. I have custom code in place that triggers a cred_save_data hook when this page loads, and the code grabs post_ids from the URL parameter to update those posts. Multiple post IDs are added to the URL successfully, but only one post is actually updated by the cred_save_data hook.
Solution: To access URL parameters in a cred_save_data hook, find them in $_GET instead of $_POST:
$url_params = $_GET['post_ids'];
Also be sure to use the square bracket notation to indicate multiple values are included:
https://yoursite.com/delegate-update-results/?post_ids[]=44175&post_ids[]=44163&post_ids[]=44162
Then you must update your code to work with an array of values instead of a comma-separated string.
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 2 replies, has 2 voices.
Last updated by 4 years, 11 months ago.
Assisted by: Christian Cox.