Skip Navigation

[Resolved] Change post status using a form

This support ticket is created 3 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.

Sun Mon Tue Wed Thu Fri Sat
9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 - - 9:00 – 13:00
14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 - - 14:00 – 18:00

Supporter timezone: Africa/Casablanca (GMT+01:00)

This topic contains 7 replies, has 2 voices.

Last updated by Jamal 3 years, 11 months ago.

Assisted by: Jamal.

Author
Posts
#1917797

Ah ok good to know I guess that is just for backend debug but once again great tool.

Now I have created a Front end Form for editing as well only thing is to make changes to post satus via Post Editing front end from would be great if you can see it today and help me out further as well. Then I don't have to explain it to any one else.

#1917801

If I remember well, you want to have a dropdown with all the statuses, so you can choose what status to set for the post, right? Or do you want to change to a specific status?

#1917873

yes you are right as that a emplyee can change the post status so that based on that status posts are displayed on front end for all user.

#1917875

for all visiters

#1917877

But main concept is after post come .. it saved as draft or pending after review emply can either move it to publish or to trash and if select publish it should be published in view where only published posted are being showed to visitors

#1920295

still waiting for your response.

#1921859

Still waiting for your response ... stragen still no response ...

#1923877

My apologies for the late reply, but I was not able to reply anytime sooner. I believe that I have already answered your question here https://toolset.com/forums/topic/update-post-status-from-the-frontend/#post-1910577 and I suggested implementing the solution here https://toolset.com/forums/topic/manage-native-wordpress-post-status-in-cred-form/#post-489972

So, I created a test site to show you how that's implemented. You can log in with this URL hidden link
The form is here hidden link
The view is in here hidden link
The custom code here hidden link
Form code:

[credform]
	<div class="form-group">
	<label>[cred_i18n name='generic-filed-status-label']Status[/cred_i18n]</label>
	[cred_generic_field type='select' field='status']
{
"required":0,
"default":"0",
"options":[{"value":"0","label":"Select"},{"value":"draft","label":"Draft"},{"value":"pending","label":"Pending"},{"value":"publish","label":"Publish"}]
}
[/cred_generic_field]
	</div>
	[cred_field field='form_submit' output='bootstrap' value='Submit' class='btn btn-primary btn-lg']
[/credform]

Custom code:

add_action('cred_save_data','func_update_post_status',10,2);
function func_update_post_status($post_id,$form_data) {
	if ( $form_data['id']==14 ) {
		$my_post['ID'] = $post_id;
		$my_post['post_status'] = $_REQUEST['status'];
		// Update the post into the database
		wp_update_post( $my_post );
    }
}