Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Show posts written by user on profile


  • djduckworth
    Member

    @djduckworth

    Is it possible to add a new link to the profile which displays the posts written by the user?

    By plugin would be ideal, but I can also modify the theme.

Viewing 25 replies - 1 through 25 (of 51 total)

  • djduckworth
    Member

    @djduckworth

    I’m not using groups, or multi sites. This is a central community blog that members can contribute to.

    Anything’s possible, but I think you’d have to write it yourself. Unless there is a plugin that loads RSS feeds in a new tab in the member profile (I haven’t seen one before).


    Roger Coathup
    Participant

    @rogercoathup

    Two solutions — simple link in profile header vs. profile tab

    For the first: just add a link to the author archive (standard WordPress) for the displayed user in the member-header file.

    For the second – Have a look at bp-skeleton component.

    Create a really stripped down version which just contains the code to set up your screen (profile tab), and in there do a simple wp_query() loop with the author ID set to the displayed user ID.


    valuser
    Participant

    @valuser

    There is (was) a plugin bp-posts-on-profile at https://wordpress.org/extend/plugins/bp-posts-on-profile/ though it is very out of date and hasn’t been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress and BuddyPress.

    I have tried it out with bp 1.6 and wp 3.4.1 and with a host of other bp plugins in a multisite and also in a multi-network local test site.

    As far as Multi-Site/Multi-Network it was unsatisfactory as it only drew in blog posts from the main blog.

    It did not draw in posts from (say) a group blog.

    However for anyone who authored a post on the Main Blog it dragged in that post and showed it on their profile under the tab Posts

    Those more qualified might look at the code and see if it would take much to have it brought fully up to date and multi-site compatible.

    However as all relevant details including of posts are included in the members activity tab it probably is not as vital as other plugin development ?

    On that note is there any kind of group funding facility for plugin development. So that those who want but can’t could collectively fund those who can ? or would something like that ever work ?


    djduckworth
    Member

    @djduckworth

    Thanks Valuser, that’s very helpful. My project only has a central blog that the community contributes to anyway, so this sounds promising. I’ll give it a go and let you know how it goes. It might requires a bit of hacking if it’s so old.

    Anyone interested in some paid development to update the plugin if it isn’t working?


    djduckworth
    Member

    @djduckworth

    Just tried it out and it works perfectly :)

    Buddypress 1.6 and WordPress 3.4.1.

    However it doesn’t use the excerpt, it uses the first X of the post. It actually pulls quite a lot which is not so good for SEO since it will produce a lot of duplicate content.

    I’ll see if I can find where it defines how much to pull in from the post.


    djduckworth
    Member

    @djduckworth

    I tried pasting the code in backticks, but the post doesn’t seem to show up.

    Just wondering if there is a way to modify the plugin code to use the excerpt rather than first few paragraphs.


    @mercime
    Participant

    @mercime

    @djduckworth I haven’t used the plugin before. Looking at plugin files, looks like you simply just need to open up bp-posts-on-profile/includes/templates/postsonprofile/screen-one.php file with a text editor and change the_content to the_excerpt


    djduckworth
    Member

    @djduckworth

    Worked perfectly! Thanks @mercime.


    azchipka
    Participant

    @azchipka

    OK went through the plugin and updated the code to function in current versions of buddy press, its a bit sloppy but it does work. Just place the below code in your bp-custom.php file and it will add a new tab to each users profile that displays the blog posts they have written. Display is based off of your archive.php file so it matches the theme.

    //POSTS ON PROFILE STARTS HERE
    add_action( 'bp_setup_nav', 'add_profileposts_tab', 100 );
    function add_profileposts_tab() {
    global $bp;
    bp_core_new_nav_item( array(
    'name' => 'My Posts',
    'slug' => 'posts',
    'screen_function' => 'bp_postsonprofile',
    'default_subnav_slug' => 'My Posts', 
    'position' => 25
    )
    );
    // show feedback when 'Posts' tab is clicked
    function bp_postsonprofile() {
    add_action( 'bp_template_content', 'profile_screen_posts_show' );
    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
    }
    
    function profile_screen_posts_show() {
    $theuser = bp_displayed_user_id(); 
    query_posts("author=$theuser" );
    get_template_part( 'loop', 'archive' ); //call your archive template
    
    }
    
    }
    
    //POSTS ON PROFILE ENDS HERE

    azchipka
    Participant

    @azchipka

    Sorry there was an error in the above code, that results in a no results dialog error for users who have no posts. You can download a bundled plugin by clicking here.

    if ( !function_exists( 'add_action' ) ) {
    	echo 'Hi there!  I\'m just a plugin, not much I can do when called directly.';
    	exit;
    }
    define('TCH_PostsOnProfilesVersion', '0.1');
    define('TCH_PostsOnProfilesVersion_PLUGIN_URL', plugin_dir_url( __FILE__ ));
    
    add_action( 'bp_setup_nav', 'add_profileposts_tab', 100 );
    function add_profileposts_tab() {
    global $bp;
    bp_core_new_nav_item( array(
    'name' => 'My Posts',
    'slug' => 'posts',
    'screen_function' => 'bp_postsonprofile',
    'default_subnav_slug' => 'My Posts', 
    'position' => 25
    )
    );
    // show feedback when 'Posts' tab is clicked
    function bp_postsonprofile() {
    add_action( 'bp_template_content', 'profile_screen_posts_show' );
    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );
    }
    
    function profile_screen_posts_show() {
    $theuser = bp_displayed_user_id(); 
    query_posts("author=$theuser" );
    if ( have_posts() ) :
    get_template_part( 'loop', 'archive' );
    else: ?>
    
    		
    
    	    

    azchipka
    Participant

    @azchipka

    Use the download link the forum keeps stripping out a portion of the code.


    @mercime
    Participant

    @mercime

    @azchipka check out BuddyBlog as well.


    Slams
    Participant

    @slams

    I’ve an issue with this code. When I try to load user post in tab I get this loop

    I don’t know why but if this part is presented, I’m getting my content looped.

    query_posts("author=$theuser" );
    if ( have_posts() ) :

    Thank you in advance!


    4ella
    Participant

    @4ella

    Hi, I have latest 1.7.2 version of Buddypress and latest version of wordpress but all I see is the tab for โ€œMy Postsโ€ but without any post in it even if those members has 5 , 100 or me 1000 posts , is it updated for latest version, still working?


    4ella
    Participant

    @4ella

    No problem, forget my questions, @mercime ‘s suggestion to take a look at Buddydev’s plugin was right, BuddyBlog works perfect with latest versions, thanks


    fitnessblogger
    Participant

    @fitnessblogger

    Hello Guys,

    I am trying to get this to work for my site http://fitnessblogger.net

    I have just downloaded @azchipka plugin but my site is multisite so not sure if that is causing a problem ??

    The “My posts” tab appears as seen here http://fitnessblogger.net/perform_rev/

    But on clicking I get a 502 bad gateway error ??

    http://fitnessblogger.net/perform_rev/posts/

    Is there a way to make this link to the users author page instead ??

    example :http://fitnessblogger.net/author/perform_rev/

    Would really appreciate any help on this one ๐Ÿ™‚

    Thank You in advance

    James


    azchipka
    Participant

    @azchipka

    @fitnessblogger and @4ella with out additional information on your configuration its hard for me to say what the issue is. The above code was written specifically to resolve the issue on one of my websites and its working perfectly there as provided above.

    Now that said its worth noting the site the code is being used on is running
    WordPress 3.6-beta3-24450. @4ella you mentioned you running the latest version of wordpress which if not the beta is 3.5.2 which 3.6 has some pretty major changes made to it so this could be part of the problem.


    fitnessblogger
    Participant

    @fitnessblogger

    Hi @azchipka

    I am just trying to download the beta now on my staging site ๐Ÿ™‚

    Thanks for the reply

    James


    azchipka
    Participant

    @azchipka

    James (@fitnessblogger),

    If installing the beta doesn’t resolve the issue, I can take a look at it for you. Might be something silly thats different on your site.

    ~Avery


    4ella
    Participant

    @4ella

    @azchipka Yes, I have Beta WordPress 3.6-beta4-24534 and also Beta 1.8 today I am going to upgrade to 1.8 full version, at this moment when I install your plugin and I click on MY POSTS tab in admin (admin has 1700 posts) I get this page:
    http://4ella.com/members/admin/posts/ which gives me PAGE NOT FOUND , I have also installed buddyblog which works perfect, but I have also many post types and I want them work too, unfortunately at this moment Brajesh’s plugin works only for one post type, your plugin works with all users post types?


    AnywhereButHollywood
    Participant

    @anywherebuthollywood

    I don’t suppose you ever found a solution for this? I’m still getting Page Not Found, with everything updated to latest and greatest.

    Unfortunately, I can’t use BuddyBlog, because it doesn’t let users post images (technically, they can edit after they post, and then add images, but that’s not what I’m looking for).

    It seems this should be an easy thing to do (but what do I know?)… just link to the author’s posts…. (sigh)


    Tecca
    Participant

    @tecca

    The problem is most likely because you don’t have a loop-archive.php. What I did instead was change some of the code to suit what I had prior: an author.php file that was already styled the way I wanted.

    In the plugin:

    function profile_screen_posts_show() {
    $theuser = bp_displayed_user_id(); 
    query_posts("author=$theuser" );
    if ( have_posts() ) :
    get_template_part( 'loop', 'archive' );
    else: ?>
    <div id="message" class="info">
    		<p><?php _e( 'Sorry, this user has not published any posts.', 'buddypress' ); ?></p>
    	</div><?php endif; ?>    <?php
    } 

    I changed it to:

    function profile_screen_posts_show() {
    query_posts( 'author=' . bp_displayed_user_id() );
    	if ( have_posts() ) :
    	get_template_part( 'author' );
    else: ?>
    	<div id="message" class="info">
    		<p><?php bp_displayed_user_username(); ?> has not published any articles or reviews. Want them to? Send a message or leave a wall post!</p>
    	</div>
        <?php endif; ?>    <?php
    }

    You’ll see in there: get_template_part( ‘author’ );
    — change “author” to whichever template part you want to call. Most installs, I believe, will have an archive.php file, so use archive.


    4ella
    Participant

    @4ella

    I have decided to create my own new tabs, which shows displayed user custom posts depending on displayed user roles, so if I have girl model, visitors see her “portfolio” tab with her curricullum (custom post=portfolio) previously created by gravity forms, the same for example for photographers who has another “photographer” tab with his custom post type=photographer with his services, photos ecc. It is much more better for me, if somebody will need those codes I can upload them here. This week I would like also to create another tab(s) (create, edit or both) with user role specific gravity form which will create that custom post directly from the user profile.


    AnywhereButHollywood
    Participant

    @anywherebuthollywood

    Here we go, FINALLY. I modified code found here…

    http://bp-fr.net/BuddyBin/?46d87fc956b8ccc9#/KMARTQxuEvpq+48vEBDWUuvlh4pJajVaiQ+mCU2rIc=

    To the following:

    // adding a subnav menu tab on a profile page for author’s posts
    // add this snippet into theme’s functions.php

    function authorposts_onprofile() {
    global $bp;
    ?>
    <li id=”activity-reshares”>” title=”<?php bp_displayed_user_fullname(); ?>’s Page”>Posts
    <?php
    }

    add_action(‘bp_member_options_nav’, ‘authorposts_onprofile’);

Viewing 25 replies - 1 through 25 (of 51 total)
  • The topic ‘[Resolved] Show posts written by user on profile’ is closed to new replies.
Skip to toolbar