Skip Navigation

[Resolved] shortcodes to change post status

This support ticket is created 4 years, 7 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 2 replies, has 2 voices.

Last updated by FuChan 4 years, 7 months ago.

Assisted by: Nigel.

Author
Posts
#1574529

I create a CPT and make a custom field (slug: ad_status, type: radio with values: 1 and 2). I want the post to become private when the field value equals 2.

I try to use following shortcodes in the Views, but it fails.
[wpv-conditional if="( $(wpcf-ad_status) eq '2' )"][wpv-post-status show="private"][/wpv-conditional]

Could you help to correct it? Thanks.

#1575239

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

When you say " I want the post to become private when the field value equals 2" you mean you want to use WordPress's private post status, yes, rather than use Access for example to hide content?

If that's the case then it seems like you need to update the post status when the post is saved, depending on the value of the custom field.

And to do that, it depends on whether you are saving the post in the backend or using a frontend form?

With the backend you would need to use the save_post WordPress hook (https://developer.wordpress.org/reference/hooks/save_post/).

With a frontend form you would use the cred_save_data hook (https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data).

If you try and are stuck, let me know.

#1576675

My issue is resolved now. Thank you!