Site icon Hip-Hop Website Design and Development

How to load specific template page in a custom shortcode

I’m using a theme for my WP site that has its own registration page template (register.php). I’m trying to create a shortcode that will load that template wherever I want, but I can’t make it work.

This is one thing I’ve tried:

function my_BP_registration_form_shortcode( $atts ) {
 ob_start();
 get_template_part( 'register' );
 return ob_get_clean();
}
add_shortcode( 'my_BP_registration_form', 'my_BP_registration_form_shortcode');

This is another thing I’ve tried:

function my_BP_registration_form_shortcode( $atts ) {
 include('/full/path/to/template/register.php');
}
add_shortcode( 'my_BP_registration_form', 'my_BP_registration_form_shortcode');

None of those 2 things work. Maybe I’m going completely wrong about this, I’m just trying to show the registration form additionally to the default WP registration page.

The shortcode works fine btw, I can place it anywhere I want and it will load whatever contents I put in that code, just not the template I want. In case it helps the template if from a theme that uses Buddypress.

EDIT:
Something important to point out is that the template I’m trying to use is inside the plugins folder (inside the Buddypress plugin). I’ve tried copying that template to my theme folder and while the file loads fine, it doesn’t work well since I assume the Buddypress dependencies it relies on aren’t loading properly from that location