[Resolved] How do I tell which form action has been clicked
This support ticket is created 6 years, 11 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Hi,
I have added an additional form action / button on my CRED form and want to detect the difference between a normal Save and my new action which is Complete. Reason for having complete is to change the status to Published. I have tried the cred_submit_complete hook with no joy. Please can you help out?
Thanks,
Si
Thank you for getting in touch with us. I would be happy to help you in this but I need some more information:
1. Are you trying to change Post’s status as = Published when it is submitted by a CRED Post Form?
2. Can you please send the link to the form page?
3. Can you please send the code or action that you have created for this?
1. Are you trying to change Post’s status as = Published when it is submitted by a CRED Post Form?
So, I want to create a Post initially as a draft. I want to be able to update it using a standard cred button
[cred_field field='form_submit' value='Save' urlparam='']
However what I'd like to have is a specific button that can save and change the status to Published when I click that button. I was hoping to be able to use a form submit button.
2. Can you please send the link to the form page?
I have uploaded an image.
3. Can you please send the code or action that you have created for this?
It is literally this:
1. We will use cred_submit_complete hook for this. Please add this code in your theme’s functions.php file, note the comments inside the code:
add_action('cred_submit_complete', 'my_success_action',10,2);
function my_success_action($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==139)// Replace 139 with your cred form ID
{
if (isset($_POST['form_submit_1']) && $_POST['form_submit_1'] == 'Save') { // Save button press - Draft code. You can remove this condition if not needed.
}
elseif(isset($_POST['form_submit_2']) && $_POST['form_submit_2'] == 'Complete Order') { // Complete Order button press - Published code
// Update post status code goes here
}
}
}