bp_blogs_post_pre_publish

Check whether the current activity about a post or a comment can be published.

Description

bp_blogs_post_pre_publish( (constant) $return = true, (int) $blog_id = 0, (int) $post_id = 0, (int) $user_id = 0 ); 

Abstracted from the deprecated bp_blogs_record_post()..

Parameters (4)

0. $return — Optional. (constant) => true
Whether the post should be published.
1. $blog_id — Optional. (int)
ID of the blog.
2. $post_id — Optional. (int)
ID of the post.
3. $user_id — Optional. (int)
ID of the post author.

Usage

  1. if ( !function_exists( 'bp_blogs_post_pre_publish' ) ) { 
  2. require_once '/bp-blogs/bp-blogs-filters.php'; 
  3.  
  4. // Whether the post should be published. 
  5. $return = true; 
  6.  
  7. // ID of the blog. 
  8. $blog_id = -1; 
  9.  
  10. // ID of the post. 
  11. $post_id = -1; 
  12.  
  13. // ID of the post author. 
  14. $user_id = -1; 
  15.  
  16. // NOTICE! Understand what this does before running. 
  17. $result = bp_blogs_post_pre_publish($return, $blog_id, $post_id, $user_id); 
  18.  

Defined (1)

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

/bp-blogs/bp-blogs-filters.php  
  1. function bp_blogs_post_pre_publish( $return = true, $blog_id = 0, $post_id = 0, $user_id = 0 ) { 
  2. $bp = buddypress(); 
  3.  
  4. // If blog is not trackable, do not record the activity. 
  5. if ( ! bp_blogs_is_blog_trackable( $blog_id, $user_id ) ) { 
  6. return false; 
  7.  
  8. /** 
  9. * Stop infinite loops with WordPress MU Sitewide Tags. 
  10. * That plugin changed the way its settings were stored at some point. Thus the dual check. 
  11. */ 
  12. $sitewide_tags_blog_settings = bp_core_get_root_option( 'sitewide_tags_blog' ); 
  13. if ( ! empty( $sitewide_tags_blog_settings ) ) { 
  14. $st_options = maybe_unserialize( $sitewide_tags_blog_settings ); 
  15. $tags_blog_id = isset( $st_options['tags_blog_id'] ) ? $st_options['tags_blog_id'] : 0; 
  16. } else { 
  17. $tags_blog_id = bp_core_get_root_option( 'sitewide_tags_blog' ); 
  18. $tags_blog_id = intval( $tags_blog_id ); 
  19.  
  20. /** 
  21. * Filters whether or not BuddyPress should block sitewide tags activity. 
  22. * @since 2.2.0 
  23. * @param bool $value Current status of the sitewide tags activity. 
  24. */ 
  25. if ( (int) $blog_id == $tags_blog_id && apply_filters( 'bp_blogs_block_sitewide_tags_activity', true ) ) { 
  26. return false; 
  27.  
  28. /** 
  29. * Filters whether or not the current blog is public. 
  30. * @since 2.2.0 
  31. * @param int $value Value from the blog_public option for the current blog. 
  32. */ 
  33. $is_blog_public = apply_filters( 'bp_is_blog_public', (int) get_blog_option( $blog_id, 'blog_public' ) ); 
  34.  
  35. if ( 0 === $is_blog_public && is_multisite() ) { 
  36. return false; 
  37.  
  38. return $return;