Hey there Johan,
I’m posting here the solution for future reference. ??
add_action( 'template_redirect', function(){
if ( ! is_user_logged_in() || ! is_page( 'test' ) ) {
return;
}
$BpfbBinder = new BpfbBinder();
add_action('wp_enqueue_scripts', array($BpfbBinder, 'js_load_scripts'));
add_action('wp_print_scripts', array($BpfbBinder, 'js_plugin_url'));
add_action('wp_print_styles', array($BpfbBinder, 'css_load_styles'));
} );
function bp_nouveau_activity_member_post_form2( $content ) {
if (is_user_logged_in() && is_page('test')) {
ob_start();
bp_get_template_part('activity/post-form');
$content .= ob_get_contents();
ob_end_clean();
}
return $content;
}
add_action('the_content', 'bp_nouveau_activity_member_post_form2');
In this snippet, I add the BP form in a specific page with slug “test”.
To incorporate with the snippet you shared , this should be changed to:
add_action( 'template_redirect', function(){
if ( ! is_user_logged_in() || ! is_page( 'test' ) ) {
return;
}
$BpfbBinder = new BpfbBinder();
add_action('wp_enqueue_scripts', array($BpfbBinder, 'js_load_scripts'));
add_action('wp_print_scripts', array($BpfbBinder, 'js_plugin_url'));
add_action('wp_print_styles', array($BpfbBinder, 'css_load_styles'));
} );
function bp_nouveau_activity_member_post_form2() {
if (is_user_logged_in()) {
ob_start();
bp_get_template_part('activity/post-form');
$output = ob_get_contents();
ob_end_clean();
}
return $output;
}
Take care,
Dimitris