I'm trying to implement do_shortcode functionality for Profile Builder plugin to load the registration form when it's called from the login form. Since the form will be displayed in the same modal window that requires that the registration form needs to be loaded by AJAX.
In functions.php there is a function to load shortcode content:
add_action( 'wp_ajax_nopriv_do_shortcode', 'do_shortcode' );
add_action( 'wp_ajax_do_shortcode', 'do_shortcode' );
function do_shortcode( ) {
$shortcode = $_REQUEST['shortcode_name'];
ob_start();
echo do_shortcode( $shortcode );
ob_get_contents();
$modal = ob_get_clean();
echo $modal;
die();
}
And in modal window template I've have:
function load() {
jQuery.ajax({
method: 'POST',
url: '/wp-admin/admin-ajax.php',
data: {
action: 'do_shortcode',
shortcode_name: 'wppb-register'
},
success: function(data)
{
jQuery("#my-modal").replaceWith(data);
}
});
}
In result I'm receiving only the 'wppb_register' text. How could I get the registration form that is content for this shortcode?