Skip Navigation

[Résolu] Change Draft to Publish using button

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.

This topic contains 7 réponses, has 2 voix.

Last updated by anilA Il y a 7 années et 3 mois.

Assigned support staff: Caridad.

Auteur
Publications
#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.!