bp_core_get_all_posts_for_user

Fetch every post that is authored by the given user for the current blog.

Description

(array) bp_core_get_all_posts_for_user( (int) $user_id = 0 ); 

No longer used in BuddyPress.

Returns (array)

Post IDs.

Parameters (1)

0. $user_id — Optional. (int)
ID of the user being queried.

Usage

  1. if ( !function_exists( 'bp_core_get_all_posts_for_user' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-members/bp-members-functions.php'; 
  3.  
  4. // ID of the user being queried. 
  5. $user_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = bp_core_get_all_posts_for_user($user_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/bp-members/bp-members-functions.php  
  1. function bp_core_get_all_posts_for_user( $user_id = 0 ) { 
  2. global $wpdb; 
  3.  
  4. if ( empty( $user_id ) ) { 
  5. $user_id = bp_displayed_user_id(); 
  6.  
  7. return apply_filters( 'bp_core_get_all_posts_for_user', $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM {$wpdb->posts} WHERE post_author = %d AND post_status = 'publish' AND post_type = 'post'", $user_id ) ) );