• Resolved johanmc

    (@johanmc)


    I’m using the following code to show the form on another page:

    
    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;
    }
    

    but the form is generated without ‘bpfb_actions_container’.

    How can I solve this problem?

    Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Dimitris – WPMU DEV Support

    (@wpmudev-support6)

    Hello there @johanmc,

    hope you’re doing good today! ??

    Could you please send me an email to [email protected] using this template:

    Subject: “Attn: Dimitris

    – link back to this thread for reference

    Keep in mind the subject line as ensures that it gets assigned to me.
    Thank you,
    Dimitris

    Plugin Support Dimitris – WPMU DEV Support

    (@wpmudev-support6)

    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

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Load post-form in other page’ is closed to new replies.