Use PHP Buffer to Insert an ACF form into Shortcodes Ultimate Accordion

I love Advanced Custom Fields and Shortcodes Ultimate, but making them play well together can be elusive. If you’re like me, you may think that the following code will place an ACF form inside a Shortcodes Spoiler:

echo do_shortcode('[su_accordion][su_spoiler title="New Post" style="fancy"]' . acf_form($args) . '[/su_spoiler][/su_accordion]');

But because of the way the form renders, it ends up outside of the accordion. The trick is to use PHP output buffering to assign the form output to a variable first. Then place the variable inside the shortcode: