Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Created April 22, 2019 22:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/dd130990adf4dca9241cce796aeb02f1 to your computer and use it in GitHub Desktop.
Save KaineLabs/dd130990adf4dca9241cce796aeb02f1 to your computer and use it in GitHub Desktop.
Get User Photo Posts Count. [yz_total_activity_photos]
<?php
/**
* Get User Photo Posts Count. [yz_total_activity_photos]
*/
function yzc_get_total_photo_posts_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_photo'";
if ( ! empty( $args['user_id'] ) ) {
$request .= " AND user_id = {$args['user_id']} ";
}
return $wpdb->get_var( $request );
}
add_shortcode( 'yz_total_activity_photos', 'yzc_get_total_photo_posts_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment