bp_blogs_delete_blogmeta

Delete a metadata from the DB for a blog.

Description

bp_blogs_delete_blogmeta( (int) $blog_id, (constant) $meta_key = false, (constant) $meta_value = false, (bool) $delete_all = false ); 

Parameters (4)

0. $blog_id (int)
ID of the blog whose metadata is being deleted.
1. $meta_key — Optional. (constant) => false
The key of the metadata being deleted. If omitted, all BP metadata associated with the blog will be deleted.
2. $meta_value — Optional. (constant) => false
If present, the metadata will only be deleted if the meta_value matches this parameter.
3. $delete_all — Optional. (bool) => false
If true, delete matching metadata entries for all objects, ignoring the specified blog_id. Otherwise, only delete matching metadata entries for the specified blog. Default: false.

Usage

  1. if ( !function_exists( 'bp_blogs_delete_blogmeta' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-blogs/bp-blogs-functions.php'; 
  3.  
  4. // ID of the blog whose metadata is being deleted. 
  5. $blog_id = -1; 
  6. $meta_key = false; 
  7.  
  8. // Optional. If present, the metadata will only be 
  9. // deleted if the meta_value matches this parameter. 
  10. $meta_value = false; 
  11. $delete_all = false; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = bp_blogs_delete_blogmeta($blog_id, $meta_key, $meta_value, $delete_all); 
  15.  

Defined (1)

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

/bp-blogs/bp-blogs-functions.php  
  1. function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false, $delete_all = false ) { 
  2. global $wpdb; 
  3.  
  4. // Legacy - if no meta_key is passed, delete all for the blog_id. 
  5. if ( empty( $meta_key ) ) { 
  6. $keys = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM {$wpdb->blogmeta} WHERE blog_id = %d", $blog_id ) ); 
  7. $delete_all = false; 
  8. } else { 
  9. $keys = array( $meta_key ); 
  10.  
  11.  
  12. $retval = false; 
  13. foreach ( $keys as $key ) { 
  14. $retval = delete_metadata( 'blog', $blog_id, $key, $meta_value, $delete_all ); 
  15.  
  16.  
  17. return $retval;