Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Total Activity Comments Shortcode [yz_total_activity_comments user_id=""]
<?php
/**
* Get User Comments Count.
*/
function yzc_get_total_comments_shortcode( $args = null ) {
global $bp, $wpdb;
// Get Shortcode Args.
$args = wp_parse_args( $args, array(
'user_id' => false,
)
);
// Get Global Request
$request = "SELECT COUNT(*) FROM {$bp->activity->table_name} WHERE component = 'activity' AND type = 'activity_comment'";
if ( ! empty( $args['user_id'] ) ) {
$request .= " AND user_id = {$args['user_id']} ";
}
return $wpdb->get_var( $request );
}
add_shortcode( 'yz_total_activity_comments', 'yzc_get_total_comments_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment