Comment Code Issue

  • In Progress
    Posted in: Game Addict  
  • Member
    October 22, 2014 at 8:07 pm #51329

    I am trying to incorporate a userpro plug in to work with the comments section on this template. My instructions are as follows:

    This guide will help you show the user profile picture, profile link, user badges and display name to your comments. Each theme is different but often you have a comments.php file, open that file and find this part: wp_list_comments( array( ‘callback’ => ‘presscore_comment’ ) ); The callback will be different for each theme, so you just need to find this function inside your theme files, in this example, we are using the dream-theme and the callback presscore_comment is located in functions.php this can be different for each theme though. The callback function includes your actual comment template. Once you locate this function, edit the following parts to in the function to replace existing comments and integrate UserPro stuff in it. Here are steps:

    STEP 1: Define global of UserPro : You must define this line global $userpro; just after the callback function has started. In this example, it looks like this :

    function presscore_comment( $comment, $args, $depth ) {
    global $userpro;

    STEP 2: Use UserPro profile picture (avatar) : Change the part that displays user avatar in your comments to:

    echo get_avatar( $comment, 60 );

    This short line will display user avatar, 60 is the size you want. You can customize the comments avatar size using this option. That’s it for the avatar, UserPro avatars now integrated in comments.

    STEP 3: Display user profile link & name : Find the part that displays comment author link or name and replace it with this function:

    if ($comment->user_id) {
    printf(‘%s’, ‘permalink( $comment->user_id ).'”>’.userpro_profile_data(‘display_name’, $comment->user_id) . ‘‘);
    else {
    printf(‘%s’, get_comment_author_link());

    What did we do? Simply we need to check if the commenter has an ID (profile) by testing $comment->user_id, then we display his permalink, and profile data (display name) that’s all. If he does not have an account, the normal author link will display.

    STEP 4: Display user badges :To display user badges in your comments, simply add this code to your comments function where you want to show the badges (This can be different for your needs) maybe beside commentor name is a good option. So you just need to insert the following snippet to show the badges for any registered user.

    echo userpro_show_badges($comment->user_id, $inline=true);

    That will show the user badges for comment author. Ofcourse you need to check that he is not a guest using $comment->user_id check.

    I cant seem to find wp_list_comments( array( ‘callback’ => ‘presscore_comment’ ) ); within your code… can you please help!

    Sorry, this forum is for verified users only. Please Login or Register to continue

Comments are closed.