bp_blogs_delete_blogmeta( int $blog_id, string|bool $meta_key = false, string|bool $meta_value = false, bool $delete_all = false )
Delete a metadata from the DB for a blog.
Description
Parameters
- $blog_id
-
(int) (Required) ID of the blog whose metadata is being deleted.
- $meta_key
-
(string|bool) (Optional) The key of the metadata being deleted. If omitted, all BP metadata associated with the blog will be deleted.
Default value: false
- $meta_value
-
(string|bool) (Optional) If present, the metadata will only be deleted if the meta_value matches this parameter.
Default value: false
- $delete_all
-
(bool) (Optional) 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.
Default value: false
Return
(bool) True on success, false on failure.
Source
File: bp-blogs/bp-blogs-functions.php
function bp_blogs_delete_blogmeta( $blog_id, $meta_key = false, $meta_value = false, $delete_all = false ) { global $wpdb; // Legacy - if no meta_key is passed, delete all for the blog_id. if ( empty( $meta_key ) ) { $keys = $wpdb->get_col( $wpdb->prepare( "SELECT meta_key FROM {$wpdb->blogmeta} WHERE blog_id = %d", $blog_id ) ); $delete_all = false; } else { $keys = array( $meta_key ); } add_filter( 'query', 'bp_filter_metaid_column_name' ); $retval = false; foreach ( $keys as $key ) { $retval = delete_metadata( 'blog', $blog_id, $key, $meta_value, $delete_all ); } remove_filter( 'query', 'bp_filter_metaid_column_name' ); return $retval; }
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.