Skip to:
Content
Pages
Categories
Search
Top
Bottom

Member Names & Avatars Not Showing


  • john
    Participant

    @johnpaulbeaver

    Comments from non-members are displaying on the front end and I verified it’s still recording activity for guest comments correctly in the DB, but the user’s name and avatar are no longer appearing on the front end on buddypress 2.0.2.

    Plugin hasn’t been updated since last March so I’m not sure if its author has lost interest. I went through the code and don’t know the buddypress core well enough to figure out what’s going on (or rather, what’s not going on).

    Any help would be much appreciated, as I’ve found allowing guest comments and featuring them in the activity feed has helped to increase member signup rates significantly.

    https://wordpress.org/plugins/bp-include-non-member-comments/

    bp-include-non-member-comments.php

    /* Only load the BuddyPress plugin functions if BuddyPress is loaded and initialized. */
    function bp_include_non_member_comments_init() {
    require( dirname( __FILE__ ) . '/bp-include-non-member-comments-bp-functions.php' );

    add_action( 'comment_post', 'bp_blogs_record_nonmember_comment', 8, 2 );

    add_action('wp_set_comment_status', 'bp_blogs_record_nonmember_comment_approved', 8, 2 );
    add_filter( 'bp_activity_content_filter', 'bp_nonmember_comment_content', 10, 4 );
    }
    add_action( 'bp_init', 'bp_include_non_member_comments_init' );

    bp-include-non-member-comments-bp-functions.php

    function bp_blogs_record_nonmember_comment_approved( $comment_id, $comment_status ) {
    if ( $comment_status = 'approve' )
    bp_blogs_record_nonmember_comment( $comment_id, 1 );
    }

    function bp_blogs_record_nonmember_comment( $comment_id, $is_approved ) {
    global $wpdb, $bp;

    if ( !$is_approved )
    return false;

    $comment = get_comment($comment_id);

    if ( empty( $comment ) ) {
    return;
    }

    /* Thanks, Andrius! */
    if ( $comment->comment_approved == 'spam' )
    return false;

    if ( email_exists( $comment->comment_author_email ) )
    return false;

    $comment->post = get_post( $comment->comment_post_ID );

    /* If this is a password protected post, don't record the comment */
    if ( !empty( $post->post_password ) )
    return false;

    if ( (int)get_blog_option( $comment->blog_id, 'blog_public' ) || !bp_core_is_multisite() ) {
    /* Record in activity streams */
    $comment_link = get_permalink( $comment->comment_post_ID ) . '#comment-' . $comment_id;

    $activity_action = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), 'comment_author_url . '">' . $comment->comment_author . '', '' . $comment->post->post_title . '' );

    $activity_content = $comment->comment_content;

    /* Record this in activity streams */
    bp_blogs_record_activity( array(
    'user_id' => false,
    'action' => apply_filters( 'bp_blogs_activity_new_comment_action', $activity_action, $comment, $comment, $comment_link ),
    'content' => apply_filters( 'bp_blogs_activity_new_comment_content', $activity_content, $comment, $comment, $comment_link ),
    'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, $comment, $comment ),
    'type' => 'new_blog_comment',
    'item_id' => $wpdb->blogid,
    'secondary_item_id' => $comment_id,
    'recorded_time' => $comment->comment_date_gmt
    ) );
    }

    return $comment;
    }

    /* For BP < 1.2 */
    function bp_blogs_record_nonmember_comment_old( $comment_id, $is_approved ) {
    global $wpdb, $bp;

    if ( !$is_approved )
    return false;

    $comment = get_comment($comment_id);
    $comment->post = get_post( $comment->comment_post_ID );

    /* If this is a password protected post, don't record the comment */
    if ( !empty( $post->post_password ) )
    return false;

    $recorded_comment = new BP_Blogs_Comment;
    $recorded_comment->user_id = $user_id;
    $recorded_comment->blog_id = $wpdb->blogid;
    $recorded_comment->comment_id = $comment_id;
    $recorded_comment->comment_post_id = $comment->comment_post_ID;
    $recorded_comment->date_created = strtotime( $comment->comment_date );

    $recorded_commment_id = $recorded_comment->save();

    bp_blogs_update_blogmeta( $recorded_comment->blog_id, 'last_activity', time() );

    if ( (int)get_blog_option( $recorded_comment->blog_id, 'blog_public' ) ) {
    /* Record in activity streams */
    $comment_link = bp_post_get_permalink( $comment->post, $recorded_comment->blog_id );
    $activity_content = sprintf( __( '%s commented on the blog post %s', 'buddypress' ), 'comment_author_url . '">' . $comment->comment_author . '', 'comment_ID . '">' . $comment->post->post_title . '' );
    $activity_content .= '

    ' . bp_create_excerpt( $comment->comment_content ) . '

    ';

    /* Record this in activity streams */
    bp_blogs_record_activity( array(
    'user_id' => $recorded_comment->user_id,
    'content' => apply_filters( 'bp_blogs_activity_new_comment', $activity_content, comment, recorded_comment, $comment_link ),
    'primary_link' => apply_filters( 'bp_blogs_activity_new_comment_primary_link', $comment_link, comment, recorded_comment ),
    'component_action' => 'new_blog_comment',
    'item_id' => $comment_id,
    'secondary_item_id' => $recorded_comment->blog_id,
    'recorded_time' => $recorded_comment->date_created
    ) );
    }

    return $recorded_comment;
    }

    function bp_nonmember_comment_content( $content ) {
    global $bp;

    if ( $bp->loggedin_user->id != 0 )
    return $content;

    /* Todo: Add patch to core that makes these buttons not appear for user_id=0 */
    $content = preg_replace( "|(View).*?Delete</span>|", '$1</span>', $content ); // for bp-default 1.2+
    $content = preg_replace( "|<span class=\"activity-delete-link.+?</span>|", '', $content ); // for bp-classic

    return $content;
    }

Viewing 7 replies - 1 through 7 (of 7 total)

  • john
    Participant

    @johnpaulbeaver

    I will note the desired functionality would be for non-members to have gravatars generated on the front end based on the email addresses they entered while submitted a comment as a guest.


    danbp
    Moderator

    @danbp


    john
    Participant

    @johnpaulbeaver

    I appreciate the links to gravatar integration, but they don’t address the topic of this thread.

    The issue is with the way the above code is grabbing member names and email addresses. The plugin has all guest users’ activity being stored under an arbitrary Userid 0, then cross matches that activity with the meta data for the guests’ post from comments and formats for display on the front end.

    For some reason, it no longer does that I just can’t pinpoint what’s going wrong.


    danbp
    Moderator

    @danbp

    I don’t use or know how this plugin works. And the only support question is yours.
    Boone is also the bp lead dev, so it’s it’s almost impossible that the plugin does not work with BP, especially if the last update is only a few mounth back.

    That said, the last update was on march 2013. But with over 2.000 downloads and only one support question, this plugin work’s for 99.9% of it users. I guess.

    I would suggest you deactivate any of your plugins except BP and this plugin, and make a debug visit on your site. Deactivate also your theme and use 2014 or 2013 for the test.


    john
    Participant

    @johnpaulbeaver

    “it’s almost impossible that the plugin does not work with BP”
    “with over 2.000 downloads and only one support question, this plugin work’s for 99.9% of it users. I guess.”

    Well don’t know what to tell you other than it doesn’t. The plugin wasn’t updated after updates to buddypress and has become non-functional, which is why I posted this thread to see if anyone more knowledgeable with the core code than I could easily decipher why.


    danbp
    Moderator

    @danbp

    Did you allowed comments to all ?
    dashboard > settings > buddypress > settings tab
    check Blog & Forum Comments [ ] Allow activity stream commenting on blog and forum posts.
    Also control your settings in WP settings > discussion

    You can also activate 2014 theme and test if something change in the plugin behaviour…


    john
    Participant

    @johnpaulbeaver

    *SIGH*

    Yes, the comments display on the posts, the only issue is the display names and avatars are not displaying in the site activity IE the very first sentence of my very first post:

    “Comments from non-members are displaying on the front end and I verified it’s still recording activity for guest comments correctly in the DB, but the user’s name and avatar are no longer appearing on the front end on buddypress 2.0.2.”

    There’s obviously an issue with the way this is being queried that worked in prior versions but doesn’t work in this version. Again, I’m just not familiar enough with the core to figure out what that is.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Member Names & Avatars Not Showing’ is closed to new replies.
Skip to toolbar