diffrent output on facebook imported comments?

I want to give the imported Facebook comments an extra class for additional css, so it's visible that they come from Facebook. I also would like to remove te link to their profile page from those comments. Is it possible and how?

  • Sajid

    Hi Richard,

    Greetings and hope you are doing good today :slight_smile:

    To add custom class with comments imported from facebook, add below code in functions.php file of your theme or child theme (recommended).

    /*
    	------------------------------------------------------------------------
    	This fucntion will add custom class with fb comments only
    	------------------------------------------------------------------------
    */
    function insert_fbc_into_comment_class( $classes, $class, $comment, $object )
    {	
    
    	$fb_comment = get_comment_meta( $object->comment_ID, $key = 'wdfb_comment', $single = true );
    
    	if($fb_comment){
    		$classes[] = 'fb_comment';
    	}
    
    	return $classes;
    }
    add_filter( 'comment_class', 'insert_fbc_into_comment_class', 10, 4 );

    To remove profile link from comments imported from facebook, add below code in functions.php file of your theme or child theme (recommended).

    /*
    	------------------------------------------------------------------------
    	This fucntion will remove profile link from fb comments only
    	------------------------------------------------------------------------
    */
    function wpmu_remove_fb_author_weburl($return) {
    	global $comment, $post;
    
    	if( is_admin() ) return $return; //only run outside dashboard  
    
    	$fb_comment = get_comment_meta( $comment->comment_ID, $key = 'wdfb_comment', $single = true );
    
    	if($fb_comment){
     		$author = get_comment_author( get_comment_ID() );
    
    		return $author;
    	} else {
    		return $return; //return default
    	}
    
    }
    add_filter( 'get_comment_author_link', 'wpmu_remove_fb_author_weburl');

    Let me us know how it goes :slight_smile:

    Cheers!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.