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.
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
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.
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
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 );
}
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
Yes i did. "Keep original status" is selected as well as
[credform class="cred-form cred-keep-original"]
Unsure how i can solve this.
Sorry, its working,.... somewhere down the functions line this " } " was the problem and wordpress never showed a syntax problem till now.
Thanks.!