Home Forums Plugin Support WP User Frontend Pro Display posts in profile

This topic is: not resolved

This topic contains 2 replies, has 2 voices, and was last updated by  yoann bournazaud 3 years, 7 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #72946

    yoann bournazaud
    Member
    Post count: 25

    Hello,

    I have

    1) Is it possible to display the post of a user in his buddypress profile?

    2) Is it possible that everybody can see the posts that a user has created?

    Thank you very much,

    Yoann

    #73391

    towhid
    Participant
    Post count: 4505

    Hello,

    You have to customize the plugin to display the post of a user in his buddypress profile and to show that post to all user. Right now we do not have this kind of feature.

    Thanks

    #73404

    yoann bournazaud
    Member
    Post count: 25

    I find this code and works 🙂 Thanks

    function bpfr_my_post_on_profile() {
     
        // to get all post, comment the line 'author' 
         
        $myposts = get_posts(  array(
        'posts_per_page' => 50, // set the number of post to show
        'author'         => bp_displayed_user_id(), // show only this member post
        'post_type'      => 'post',
        'orderby'          => 'post_date',
        'order'            => 'DESC',
        'post_status'      => 'publish'
        ));
         
        if( ! empty( $myposts ) ) { 
     
            foreach($myposts as $post) {
                setup_postdata( $post );
                $page_object = get_post( $post );
                 
            // uncomment next line to show only a list of titles linked to full post
            // if you uncomment, you have to comment the 2 echo below
             
                echo '<h3 class="profile_post"><a target="_blank" href="' . get_permalink($post->ID) . '">Titre: ' . get_the_title($post->ID) . '</h3></a>';
                             
            // comment the 2 following lines (or remove them) if you use the above      
                 
                //echo '<h3 class="profile_post"><a href="' . get_permalink($post->ID) . '">' . get_the_title($post->ID) . '</h3></a>';
                //echo $page_object->post_content;
            }   
         
            wp_reset_postdata();    
     
        } else { 
             
            echo '<div class="info" id="message">' . __("Aucun article trouvé.") . '</div>'; // is translated by WP
        }
    }
    add_action ( 'my_profile_post', 'bpfr_my_post_on_profile' );
     
     
    function bpfr_post_profile_setup_nav() {
        global $bp;
        $parent_slug = 'article';
        $child_slug = 'posts_sub';  
         
        bp_core_new_nav_item( array(
        'name' => __( 'Voir les articles de ce membre' ),
        'slug' => $parent_slug,
        'screen_function' => 'bpfr_profile_post_screen',
        'position' => 150,
        'default_subnav_slug' => $child_slug
        ) );
         
        //Add subnav item    
        bp_core_new_subnav_item( array( 
        'name' => __( '' ), 
        'slug' => $child_slug, 
        'parent_url' => $bp->loggedin_user->domain . $parent_slug.'/', 
        'parent_slug' => $parent_slug, 
        'screen_function' => 'bpfr_profile_post_screen'
        ) );
    }
     
    function bpfr_profile_post_screen() {   
        add_action( 'bp_template_content', 'bpfr_profile_post_screen_content' );
        bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
    }
     
    function bpfr_profile_post_screen_content() {
     
        do_action( 'my_profile_post' );
    }
     
    add_action( 'bp_setup_nav', 'bpfr_post_profile_setup_nav' );
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Display posts in profile’ is closed to new replies.