Sauter la navigation

[Résolu] User can show/hide content using a bootstrap switch button

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

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

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

Dernière mise à jour par Minesh Il y a 5 années et 5 mois.

Assisté par: Minesh.

Auteur
Publications
#1294823
screenshot_.jpg

Tell us what you are trying to do?
I'm not sure if it's possible to do and what would be the better approach to reach it.
What I want is give user the option to show or hide their own content using a switch button.

Is there any documentation that you are following?
No. Just asking for some guide or suggestion here.

Is there a similar example that we can see?
I attached an screenshot of what I would like to have.
Some contents in the BP user profile with their switch button to show or hide the content when user wants.

What is the link to your site?
lien caché

Thanks Minesh.
🙂

#1294893

Sorry Minesh, I didn't see your answer on time.

You asked me if the buttons were added to each post or were sections.

I would like to add them to each post, so if a user have (for example) 5 posts published they can show any of them (or all of them, actually).

If you need more information just ask me.

Thanks for the answer. Sorry I didn't see it.
🙂

#1295011

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

There is no option to control the single post but you can control the view conditionally. Where you should save setting somewhere and display the view conditionally using the [wpv-conditional] shortcode.

More info:
=> https://toolset.com/documentation/beyond-the-basics/conditionally-show-content/

#1295623

Hi again Minesh.
Thanks for your answer.

I'm wondering if it could be an option to use something like "Save as Draft" / "Publish" option.
I mean, I know that it is possible to include a "Save as Draft" / "Publish" inside a form.
(I read your answer here
https://toolset.com/forums/topic/i-need-to-display-submit-button-and-draft-button-in-the-same-post-form/
and there are lots of topics with the same workaround in the forum)

Could it be this approach useful to reach what I am looking for?

If it is possible I would not like to insert this "Save as Draft" / "Publish" option inside the form, but just like an "Edit form button" (which goes obviously outside the form), but with the "Save as Draft" / "Publish" option, instead of "Edit".

-> Summarizing: Could it be possible to insert an option of "Save as draft" and not show public content saved as "Draft", right?

Just asking...
🙂

Thanks Minesh

#1295655

Hi again Minesh.
I want to add some information.

-> I tried to add this code you provided to another user in the link I mentioned before.

[cred_generic_field field="post_status" type="radio" class="" urlparam=""]
{
"persist":1,
"required":0,
"validate_format":0,
"default":["publish"],
"options":[
{"value":"draft","label":"Draft"},
{"value":"publish","label":"Publish"}
]
}
[/cred_generic_field]

It shows the radio button perfectly, but while I inserted it in an "edit post form" it doesn't seem to change the post status when I save the post. I guess it is because I have selected "Status of the post after submitting the form: Publish"

Which option should I select in order to save the edit form as "draft" (as selected in the radio button) instead of publish?

Thanks again Minesh.

#1295727

Minesh
Supporter

Les langues: Anglais (English )

Fuseau horaire: Asia/Kolkata (GMT+05:30)

To save it as a draft by default. You just need to replace default argument with "draft":

"default":["draft"],