Navigation überspringen

[Gelöst] Conditionally display edit form

This support ticket is created vor 3 Jahren, 5 Monaten. 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
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: Africa/Casablanca (GMT+01:00)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von NickC8880 vor 3 Jahren, 5 Monaten.

Assistiert von: Jamal.

Author
Artikel
#2123111

I have been able to review this now.

After a bit of tinkering, I got the redirection to work as desired, which was the concern of bulk of my initial post in this ticket. Thanks for that!

However, since you have said that it is possible to have an "edit form conditionally appear on the same page as where the form data is being displayed", I'd like to figure out how to do this.

The cred_form shortcode works, but I can't figure out how this can be used to conditionally display the form and hide the rest of the content template, for example after clicking an Edit Profile button. The shortcode just seems to work the same as inserting a Form block or Fields and Text block - it just inserts the form into the content template, alongside the rest of the data being presented in the template.

Am I doing something wrong? Do I need to configure a conditional block as well? Can I use this shortcode as the link of a button?

#2123131

Well, when I said, that we can conditionally display the form, I did not mean that it is a Toolset Forms feature. We cannot configure it at the form level.

The Edit Post link feature needs a separate content template, and the link will have the content template's ID on it, so Toolset will display the post with that specific content template that holds the form.

What I meant by conditionally displaying the form, is to add some additional logic on the content template, so you will display the post to the relevant user, not to all the visitors. For example, the form can be displayed, only, to administrators. Or to the post's author. And yes, that will be implemented by a conditional block.

So, on the content template, used for displaying the post, you can add a conditional block that checks for a condition(the current user is an administrator or the author of the post), and inside of it, put the form. You can also check for a URL parameter(?edit=1), this way, you can build your own edit link that adds it to the URL, and let the conditional block display the form. Does it make sense?

I hope this helps. Let me know if you have any questions.

#2123357

Thanks, I understand - it is what I had initially suspected. I'll likely go with my original plan of having a separate page/content template for editing the post, use a conditional block as you've described here to show the current user's post, and use the snippet from the other ticket to redirect back to the profile page.