A problem with forms and shortcodes
-
So this is an odd issue. We have a form we use for users to sign up for a free trial of our product. It’s a Salesforce form that is submitted to two places – the mysql database and to a portal that directs the form along to Salesforce.
On WordPress pages where we use Page Templates > Template > Free Trial – the form works as expected. I’ve created shortcode for the form so we can reuse the form on other pages – anywhere I’ve tried the shortcode – the form loads but fails to submit properly. Every time I test it the page shows this error:
Fatal error: Call to a member function insert() on null in PATH-TO-FORM-PHP-FILE on line 56.
Here is the shortcode created in functions.php:
function free_trial() {
ob_start();
include dirname( __FILE__ ) . ‘/salesforce/content-free-trial.php’;
return ob_get_clean();
}
add_shortcode( ‘free_trial’, ‘free_trial’ );And here is Line 56 of the form php:
$wpdb->insert( $table_name, array(
// removing DB table info
) );Any ideas why the form pulled in via shorcode is not working? We have other Salesforce forms we use – with shortcodes – and they are working fine – but they aren’t sent to mysql DB or through a portal to Salesforce – they just go directly there.
- This topic was modified 8 years, 4 months ago by .
- This topic was modified 8 years, 4 months ago by .
The page I need help with: [log in to see the link]
The topic ‘A problem with forms and shortcodes’ is closed to new replies.