On one of our sites we are using a contribution form via a shortcode on a std WP page. The form is loading just fine on the page, but when the user hits the "Review Contribution" button, the shortcode itself is rendered on the page instead of the review form for the contribution page. After doing some testing on the site, it seems there is a conflict with YoastSEO. I tried to downgrade YoastSEO back to 16.6.1, and still have the issue.
This was previously working on an older version of CiviCRM for WP. Version 5.38 is working just fine and so was 5.37 of CiviCRM. But when upgrading to 5.39, the contribution shortcode is failing on the review step. Below are two vanilla instances of WP with CiviCRM and YoastSEO installed.
Both are on WP 5.7 and using the CiviCRM Demo data and WP theme. The contribution page for both of these is the default demo Membership contribution page, ID 2. The CiviCRM v5.38 install is working as expected, but v5.39 is breaking. If I remove YoastSEO, this works again on both. Since it was working before with Yoast installed, there is something introduced in 5.39 that is causing issues while having Yoast installed.
Sounds like Yoast is triggering the_content filter before the main body of your page has rendered. You should find the techniques on #107 (closed) to be helpful in solving the issue.
@kcristiano Sounds like there might need to be a re-think on the competing needs of people whose installs trigger the_content filter "pre" and/or "post" the "real" call to the_content().
Just seems odd that this is only on a postback and not the initial loading of the page and shortcode. From looking over the other issue and links from it, I would expect the issue to be even on the initial load of the page without any form interaction.
@kcristiano Yup, I reckon that's probably true. All the more reason to push forward with different kind of integration - whether via Blocks or a form builder that isn't Caldera.
I started working on a Feed Add-on for GravityForms to post a contact to Civi and also allow for pre-population to have as a profile editor as well. Didn't get into the contributions portion yet as the project didn't require that.
GravityForms repeater field was a challenge to work in, but I think it is moving forward slowly.
I think I'll add some kind of option to CiviCRM Admin Utilities that removes the remove_filter when selected. That way people can choose the old or new behaviour.
I tried looking through the code for YoastSEO and there is only one the_content in the plugin code. I was trying to figure out what was triggering the function that this was in, but broke away from it so I could get back to other client work. The action hook that is in the reference link, doesn't have any direct the_content, but when I placed the code in for specific pages, I noticed that the default CiviCRM page was failing on initial page load. But the shortcode on a page loads the form, it is just on postback that the problem comes up.
@eileen I don't think so - I have a few Yoast sites and I'll test - I think a yoast change is what happened here. Not sure it's on us to fix when plugins change. I'll let you know once I look at it.
@kcristiano I reverted Yoast back three versions and they all failed the same way. I think it has something to do with the way that 5.39 changed the rendering to fix other issues you all mentioned in terms of themes and multiple form outputs.
Now having Yoast installed was causing my issue, but prior to 5.39, or in between, this wasn't an issue even on the latest Yoast version. I think we had the client on 5.36 when we upgraded to 5.39. But from the recent talks, I think the 5.39 change is what may have caused the conflict between the two.
@kcristiano
It was odd that the shortcode would initially load the form, it was the post back that would cause the issue. But for the core frontend page for Civi, it wouldn't even load in the form on first page load while Yoast was activated on the page.
Once I used their filter to stop them from rendering to the head on the shortcode pages and frontend Civi page, things worked again as usual.
Sure, I can comment this out on the staging site for our client and then try it out on the demo installs I have in the initial comment of this issue. Looks like that is all in the commit you have.
That revert is definitely what works for us. I hadn't made the link to Yoast SEO yet, but we do run that almost everywhere....
If the problems the original change was meant to solve are related to repeated output in the loop, would it make sense to, instead of removing the filter on 'the_content' on first run, check that the current post is actually the civicrm basepage?
e.g. hacky pseudoish-code:
if(is_singular()&&in_the_loop()&&is_main_query()&&isset($_GLOBALS['post'])&&$_GLOBALS['post']->name==$config->wpBasePage){return$this->basepage_markup;}else{return$content;// CiviCRM base page is not required.}