Skip Navigation

[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.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 5 replies, has 2 voices.

Last updated by Noman 6 years, 11 months ago.

Assisted by: Noman.

Author
Posts
#525755

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

#525828

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Simon,

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?

Thank you

#525878
complete-issue.PNG

Thanks for getting back to me.

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:

	[cred_field field='form_submit' value='Save' urlparam='']
	[cred_field field='form_submit' value='Complete Order' urlparam='']
#526131

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Simon,

Thank you for providing more details. I am getting your requirements clear now and I think we can do it with some custom code, just to re-confirm:

- Save button will submit the CRED form post as = Draft
- Complete Order button will change CRED form post status as = Published

Is that right? Please let me know about it.
Thank you

#526181

That is correct Noman, many thanks in advance.
Si

#526251

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hello Simon,

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
                    	
                    	}
                    	
	}
}

2. In the above code, you can use this function to Update post status: https://codex.wordpress.org/Function_Reference/wp_update_post

3. Then use the same shortcodes in your CRED Form:

[cred_field field='form_submit' value='Save' urlparam='']
[cred_field field='form_submit' value='Complete Order' urlparam='']

I hope it helps, Thank you

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.