Tell us what you are trying to do?
I have a form for editing a Custom Post that is used for an extended User Profile in a BuddyBoss site. I am led to believe from other tickets that is quite difficult to have an edit form conditionally appear in the same page as where the form data is being displayed. (If this isn't the case, I'd like to pursue this option instead, perhaps using a button to toggle conditional blocks and/or with AJAX forms?)
So, I within the display content template have inserted a link to a separate edit form content template, and I would like for it to return the user to the profile page upon submission. The problem that I have is that the User Profile Content Template is being embedded within a tab on the BuddyBoss profile page, so I can't use the 3rd redirection option "Display the Post". Similarly, I can't use options 4 or 5 because they go to specific posts and pages.
Is it possible to use some code to redirect to a dynamic page after post submission, specifically domain.com/[logged in username]?The following function returns the user profile URL - bp_core_get_user_domain()
versteckter Link
What is the link to your site?
Here is a link to one User Profile on the site. I can provide login details in a private message.
versteckter Link
Hello and thank you for contacting Toolset support.
You can have an edit form conditionally appear on the same page as where the form data is being displayed. It just needs to know what it is editing.
A user edit form will work as expected if it was put inside a user profile page(using custom code in author.php file). Or by passing the user ID into it using the user attribute. For example:
//Display form for editing user with ID 23 (use form with title "Edit User")
[cred_user_form form="Edit User" user="23"]
https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_user_form
A post form will work as expected if used inside a content template and will let you edit the post that the content template is displaying. We can also pass the post ID to the form with the post attribute:
//Display form for editing car custom post with ID 145 (use form with title "Edit Car")
[cred_form form="Edit Car" post="145"]
https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_form
And regarding the redirection, Toolset forms have a filter that can be used to dynamically change the redirect URL. It is cred_success_redirect
https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect
Check the example on the documentation and let me know if you need help with it. In that case, I'll need more details about the form(I suspect that it is a post form for UserProfile post, right? )
Thank you very much! I'm traveling right now so can't try these out. But I'll look at it all in a few days and follow-up or close the ticket then.
You are welcome, I'll be glad if I could help. Let's mark this ticket as waiting for your feedback, which should keep it open for 2 weeks. You will receive an email notification before it is closed. Just reply and it will remain open.
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?
Thank you, I am glad I could help.
However, for support rules, we are able to handle only one issue at a time. This helps us to bring you a better service and also helps other users to find all the information here exposed. For that reason, I have created another ticket to answer your last question. I'll be posting my reply there.
Thanks very much - this is what I suspected was the case. I'll go with my original plan of having a separate page/template for editing the post, conditionally display it for the current user with the suggestions you provided in the other ticket, and then redirect back to the profile page with the snippet provided here.