Skip Navigation

[Resuelto] Change Draft to Publish using button

This support ticket is created hace 9 años, 5 meses. 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
- 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 10:00 – 19:00 -
- - - - - - -

Supporter timezone: Europe/Madrid (GMT+01:00)

This topic contains 7 respuestas, has 2 mensajes.

Last updated by anilA hace 9 años, 5 meses.

Assisted by: Caridad.

Autor
Mensajes
#229748

How can i add a button to a post or View Template to change the status of the custom post from Draft to Publish.
Just to give an overview, firstly, the frontend user submits a post, which then submits as a draft. And when the user is ready to publish it, he can click on a "Publish" button, similar to "Create" or "Edit" link for cred form.

Thank you.

#230073

Dear Anil,

You have to create a CRED form for editing. It is enough for the form to have only the submit button. You can include this form wherever you want the publish button to show:

[cred_form form="Publish Company"]

Please let me know if you are satisfied with my reply and other questions you may have.

Regards,
Caridad

#230135

What i require is:

Step 1: User creates a new post, with the option of publishing it or save it as a draft.
Step 2: User can edit the post (any status, published or draft) - and then user can have the option to publish or save as draft.

Creating the edit form is not the issue, but how can i make the user to choose to save as draft or publish the post?

Please advice.

#230741

Dear Anil,

The way things work at the moment you have 2 options:

1) You can create 2 edit forms, one for turning to draft and another for publishing. This will allow you to show 2 buttons, one for each action.

2) You can create a single edit form, with a generic field and use the 'cred_save_data' hook to change the post status:
https://toolset.com/documentation/user-guides/cred-api/#csd

Please let me know if you are satisfied with my reply and any other questions you may have.
Regards
Caridad

#230898

Hi, i tried LUOY's method from : https://toolset.com/forums/topic/allow-user-to-select-post-status-when-form-is-submitted/
but with no luck. I also tried with various "Select the status of content created by this form:" , but never did worked. Hope you can help me out.. Thanks

<div class="cred-label">Listing Status</div>

[cred_generic_field field="post_status" type="radio" class="" urlparam=""]
{
"required":0,
"validate_format":0,
"default":["publish"],
"options":[
{"value":"draft","label":"Draft"},
{"value":"publish","label":"Publish"}
]
}
[/cred_generic_field]

<br>
[cred_field field="form_submit" value="Submit" urlparam=""]
<br>
</div>
// CRED PUBLISH STATUS
add_action('cred_save_data_67', 'Select_Post_Status_func',10,2);
function Select_Post_Status_func($post_id) {
$my_post['ID'] = $post_id;
$my_post['post_status'] = $_REQUEST['post_status'];
// Update the post into the database
wp_update_post( $my_post );
}
#231028

Dear Anil,

In the CRED form, did you select "Keep original status" for the "Select the status of content created by this form:"

Regards
Caridad

#231143

Yes i did. "Keep original status" is selected as well as

[credform class="cred-form cred-keep-original"] 

Unsure how i can solve this.

#231149

Sorry, its working,.... somewhere down the functions line this " } " was the problem and wordpress never showed a syntax problem till now.

Thanks.!

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