Last active
April 22, 2019 22:03
-
-
Save KaineLabs/3b900d6facbd608a444a30bc49f2d0b3 to your computer and use it in GitHub Desktop.
Get User Video Posts Count Shortcode [yz_total_activity_videos]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get User Video Posts Count. [yz_total_activity_videos] | |
*/ | |
function yzc_get_total_videos_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_video'"; | |
if ( ! empty( $args['user_id'] ) ) { | |
$request .= " AND user_id = {$args['user_id']} "; | |
} | |
return $wpdb->get_var( $request ); | |
} | |
add_shortcode( 'yz_total_activity_videos', 'yzc_get_total_videos_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment