Skip Navigation

[Résolu] Allow the user to choose the status of their publication

This support ticket is created Il y a 2 années et 9 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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: Asia/Karachi (GMT+05:00)

Ce sujet contient 5 réponses, a 3 voix.

Dernière mise à jour par jeanL-2 Il y a 2 années et 9 mois.

Assisté par: Waqar.

Auteur
Publications
#2273991

Tell us what you are trying to do?
I want to allow the user to choose the status of their publication from a front end publication form.
In the publication form I have a multiselect field with "publish", "draft" and "pending".

Thanks 😉

#2274061

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

The form settings specify what the status of the submitted post will be.

If you want users to be able to change this you should add a generic select field with the different options, and then use the Forms API to update the status after the form submission has been handled and the post created.

You can use the cred_save_data hook for this: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

#2274115

Hi Nigel thanks for responding,

i added a generic select field with the different options in the form wich id is 31699,

I added the following code to function.php :

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

but it doesn't work.....

#2274639

Hi,

Thanks for writing back.

To troubleshoot this, I'll need to see how this form is set up in the admin area.

Can you please share temporary admin login details, along with the link to the form page?

Note: Your next reply will be private and it is recommended to make a complete backup copy, before sharing the access details.

regards,
Waqar

#2276019

Hi,

Were you able to find the solution?

Jean

#2276059

My issue is resolved now. Thank you!