I'm creating a site where visitor can create an account and after that he can create custom posts with toolset form. Now I want to let the visitor choose the visiblity of the post so that they can keep it private (default) or give it password access or publish it.
Can't find any example how to do this, is it possible?
Hi,
Thank you for contacting us and I'd be happy to assist.
To achieve this, you can use different Toolset edit post forms, one for each post status change. i.e.
a). Form to set the post status to 'private'
b). Form to set the post status to 'publish'
c). Form to set the post status to 'password protected'
These forms will not have any fields and just the submit button, as the goal of each, will only be to trigger the relevant change in the post status.
The 'Private' and 'Published' post status options are available in the form, out-of-the-box. But for the 'password protected' form some extra customization will be needed.
In that form, you'll need a generic field for a password and then a custom function attached to a 'cred_save_data' hook, to set this post as password protected with that entered password.
You'll find an example of a custom function for a similar requirement, in the following forum reply:
https://toolset.com/forums/topic/password-protect-custom-posts-with-toolset-forms/#post-1452647
I hope this helps and for more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/
regards,
Waqar
Thank you Waqar, that's brilliant!