Problem: I would like to use CRED to create a post. In that CRED form, I would like to include a checkbox that the user can check to make this a "sticky" post. If the checkbox is not checked, the post should not be "sticky".
Solution:
You need to add a generic "checkbox" field to this form. Give it a name like "stick-post" and save the value "1" when it's checked. See the attached screenshot.
Then, update this code to work with this new checkbox field's slug and form ID:
add_action('cred_save_data', 'custom_set_sticky_post',10,2); function custom_set_sticky_post($post_id, $form_data) { //update this with your form ID if ($form_data['id']==12345) { if (isset($_POST['stick-post']) && $_POST['stick-post']==1) { stick_post($post_id); } } }
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://developer.wordpress.org/reference/functions/stick_post/
https://developer.wordpress.org/reference/functions/unstick_post/
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.
Our next available supporter will start replying to tickets in about 0.99 hours from now. Thank you for your understanding.
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 6 years, 11 months ago.
Assisted by: Christian Cox.