[Resolved] toolset_edit_post_link shortcode not working inside Elementor Post Template
This thread is resolved. Here is a description of the problem and solution.
Problem:
Elementor is used to make templates for single custom posts, while Toolset Forms is used to make forms to edit the posts. When clicking the edit links the post is shown, not the edit form.
Solution:
It is necessary to include the Post Content module in the Elementor Pro template, which will be replaced by the edit form when editing the post using the Toolset Form.
This support ticket is created 5 years, 5 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I tried to replicate the code inside the template used to display my listings in the page. The problem is that I can't not Edit the post, since toolset edit_post_link shortcode appear to not work inside this instance.
The following is the error_log.php obtained in the page:
[11-Jun-2019 02:10:41 UTC] PHP Notice: Undefined index: url in /public_html/wp-content/plugins/ultimate-elementor/modules/image-gallery/widgets/image-gallery.php on line 1829
[11-Jun-2019 02:10:46 UTC] PHP Notice: Undefined variable: user_ip in /public_html/wp-content/plugins/post-views-counter/includes/counter.php on line 384
[11-Jun-2019 02:10:46 UTC] PHP Notice: Undefined variable: user_ip in /public_html/wp-content/plugins/post-views-counter/includes/counter.php on line 390
[11-Jun-2019 02:22:54 UTC] PHP Warning: Invalid argument supplied for foreach() in /public_html/wp-content/plugins/ultimate-elementor/modules/image-gallery/widgets/image-gallery.php on line 1783
[11-Jun-2019 02:24:03 UTC] PHP Notice: Undefined property: WP_Post::$filter in /public_html/wp-includes/class-wp-post.php on line 342
[11-Jun-2019 02:27:33 UTC] PHP Notice: Undefined variable: user_ip in /public_html/wp-content/plugins/post-views-counter/includes/counter.php on line 384
[11-Jun-2019 02:27:33 UTC] PHP Notice: Undefined variable: user_ip in /public_html/wp-content/plugins/post-views-counter/includes/counter.php on line 390
[11-Jun-2019 02:39:13 UTC] PHP Warning: filesize(): stat failed for /public_html/wp-content/uploads/sites/2/1970/01/bbfd2624fdb7b0fbb610390d6c8cce84-wpcf_133x106.jpg in /home/103707-78977.cloudwaysapps.com/drmjkqfgjr/public_html/wp-content/plugins/wp-optimize/includes/class-updraft-smush-manager.php on line 530
You have lots of errors reported in your debug log that you shared above, but none of them are from Toolset.
Try disabling ultimate-elementor, post-views-counter, and wp-optimize, which are responsible for the errors.
Also, in the code you shared above, the edit links look like they expect you to have an edit form inside a Layout template, but from your debug info it appears that you are not using Layouts.
Rather than copying and pasting the code from another site you should set up the post edit form from scratch, hosting it in a Content Template, and inserting the edit links using the Toolset Forms button so that they are generated correctly.
You were right. I was doing many things wrong. Finally I've done inserted the toolset_edit_post_link shortcode into the elementor template, but when I click on it, the form used to edit the listing won't open.
The code looks okay and I just tested edit links in Elementor templates on my own site and it was working okay.
Can I take a look at your site to see if I can spot the problem?
I will mark your next reply as private so that I can get log-in credentials from you—you may want to create a temporary admin user for me to use that you can later delete. And be sure to have a current backup of your site, even though I don't intend to make any changes other than testing this very issue.
Can you also confirm:
- which edit form this is
- which Elementor template is used to display the posts, of which type?
The conditional shortcodes are not working, because the wpv-current-user shortcode doesn't appear to be working.
I added another text module immediately above the module where you conditionally insert the edit link to demonstrate.
Also, if you remove all of the conditionals and simply insert the edit link directly so that it should always display, the link works, inasmuch as it reloads the page with an added URL parameter to identify the content template which contains the edit form, but the form doesn't display, the post continues to display normally.
What should happen, and what happens on my own Elementor test site, is that Forms takes control of the page and displays the edit form in place of the post itself.
I don't know if this is a live site or just a test site.
Can you repeat these tests with all non-Toolset plugins de-activated and, if necessary, with a standard theme such as twentynineteen to see if you can identify any conflicts that cause these two issues, and let me know what you find?
I did what you suggested, but I couldn't achieve the Edit Form to be triggered and displayed adequately. What I see is the current post being reloaded in a new window.
Actually this is not a live site, we are testing functionalities before launching site soon.
On my side [wpv-current-user info='role'] appears to work correctly.
Besides toolset_edit_post_link shortcode, is there another way to trigger de Edit Form for the current post, for instance, using a bootstrap button?
If the answer is no, what could I do to be able to edit the current post.
The edit form works by reloading the page with a URL parameter to specify the content template that contains the edit form, and so you could construct such a link yourself if you wanted an alternative to the link generated by the tooset_edit_post_link shortcode.
But that wouldn't solve the underlying problem, namely that the edit form isn't displaying when such a link is clicked.
I think I'll need to take a copy of the site to install locally to do some more testing, and I may need to pass it to my colleagues if I can't determine the problem myself.
I was unable to get the copy of your site to install locally so I went back in to look at your site.
Re-visiting the Elementor template for single anuncios, I believe the problem is that you have not included the Post Content module anywhere in the template.
The edit form works by replacing the post content, and if it is missing from the template there is nothing for it to replace.
It looks like you are not using the post content in the anuncios posts, but you need to include the Post Content module in the template in any case (even though it won't normally output anything, except when following the edit post link).
After Inserting Post Content Module in the template, finally Edit form was triggered in the same page.
It is not the perfect solution, since the Edit Form displays with other content already present in the page, but it is a medium resolution of my situation.