Shortcode to custom script results in 'Uh oh! Failed to save Content.'

Hello X-team!

we are using a shortcode to integrate a custom PHP script (see below) for the code. If we try to save the page we get a ‘Uh oh! Failed to save Content.’

We are now running Pro 3.1.2. - in prior versions of Pro we were able to save pages with this shortcode.

The workaround we are using is: (1) unregister shortcode (2) edit and save page (3) register shortcode. It would be nice to have a solution by which we can leave the functions.php untouched :slight_smile:

Thanks for looking into this! Have a nice day.

function members_index($params = array()) {
extract($params);
ob_start();
include(get_theme_root() . ‘/members/index.php’);
$ob_str=ob_get_contents();
ob_end_clean();
return $ob_str;
}
add_shortcode(‘members-index’, ‘members_index’);

Hi @raspberryhill,

Unfortunately, it is something related to custom code and it is outside of our support scope. From what I see of the code that you shared it might be related to whatever is inside index.php inside members folder.

You can test that by adding a sample PHP file inside members folder for example sample.php and just echo something in the PHP file. See if it worked ok on the Content Builder, if yes, then it is something inside index.php that causes the problem, if not then the code in functions.php has a problem.

If you can not find the cause of conflict you will need to hire a developer to fix the custom code and incompatibility with the Content Builder.

Thank you.

Hi Christopher,

thanks for your reply! We will do some more testing and come back on the issue.

Best,
Hendrik

You are most welcome Hendrik!

Hi Christopher, hi Ruenel,

we solved it by deactivating the code in case the shortcode is called from inside Pro, see below. Works like a charm.

Have a nice day!

function members_index($params = array()) {
if(strpos($_SERVER[‘REQUEST_URI’], ‘cornerstone-endpoint’)==1) {
$ob_str = ‘member-index’;
} else {
extract($params);
ob_start();
include(get_theme_root() . ‘/members/index.php’);
$ob_str=ob_get_contents();
ob_end_clean();
}
return $ob_str;
}

Glad you sorted things out,

Have a nice day,

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.