bp_blogs_record_blog( int $blog_id, int $user_id, bool $no_activity = false )
Make BuddyPress aware of a new site so that it can track its activity.
Description
Parameters
- $blog_id
-
(Required) ID of the blog being recorded.
- $user_id
-
(Required) ID of the user for whom the blog is being recorded.
- $no_activity
-
(Optional) Whether to skip recording an activity item about this blog creation. Default: false.
Default value: false
Return
(false|null) Returns false on failure.
Source
File: bp-blogs/bp-blogs-functions.php
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | function bp_blogs_record_blog( $blog_id , $user_id , $no_activity = false ) { if ( empty ( $user_id ) ) $user_id = bp_loggedin_user_id(); // If blog is not recordable, do not record the activity. if ( !bp_blogs_is_blog_recordable( $blog_id , $user_id ) ) return false; $name = get_blog_option( $blog_id , 'blogname' ); $url = get_home_url( $blog_id ); if ( empty ( $name ) ) { $name = $url ; } $description = get_blog_option( $blog_id , 'blogdescription' ); $close_old_posts = get_blog_option( $blog_id , 'close_comments_for_old_posts' ); $close_days_old = get_blog_option( $blog_id , 'close_comments_days_old' ); $moderation = get_blog_option( $blog_id , 'comment_moderation' ); $thread_depth = get_blog_option( $blog_id , 'thread_comments' ); if ( ! empty ( $thread_depth ) ) { $thread_depth = get_blog_option( $blog_id , 'thread_comments_depth' ); } else { // Perhaps filter this? $thread_depth = 1; } $recorded_blog = new BP_Blogs_Blog; $recorded_blog ->user_id = $user_id ; $recorded_blog ->blog_id = $blog_id ; $recorded_blog_id = $recorded_blog ->save(); $is_recorded = ! empty ( $recorded_blog_id ) ? true : false; bp_blogs_update_blogmeta( $recorded_blog ->blog_id, 'url' , $url ); bp_blogs_update_blogmeta( $recorded_blog ->blog_id, 'name' , $name ); bp_blogs_update_blogmeta( $recorded_blog ->blog_id, 'description' , $description ); bp_blogs_update_blogmeta( $recorded_blog ->blog_id, 'last_activity' , bp_core_current_time() ); bp_blogs_update_blogmeta( $recorded_blog ->blog_id, 'close_comments_for_old_posts' , $close_old_posts ); bp_blogs_update_blogmeta( $recorded_blog ->blog_id, 'close_comments_days_old' , $close_days_old ); bp_blogs_update_blogmeta( $recorded_blog ->blog_id, 'thread_comments_depth' , $thread_depth ); bp_blogs_update_blogmeta( $recorded_blog ->blog_id, 'comment_moderation' , $moderation ); $is_private = ! empty ( $_POST [ 'blog_public' ] ) && (int) $_POST [ 'blog_public' ] ? false : true; /** * Filters whether or not a new blog is public. * * @since BuddyPress 1.5.0 * * @param bool $is_private Whether or not blog is public. */ $is_private = !apply_filters( 'bp_is_new_blog_public' , ! $is_private ); /** * Fires after BuddyPress has been made aware of a new site for activity tracking. * * @since BuddyPress 1.0.0 * @since BuddyPress 2.6.0 Added $no_activity as a parameter. * * @param BP_Blogs_Blog $recorded_blog Current blog being recorded. Passed by reference. * @param bool $is_private Whether or not the current blog being recorded is private. * @param bool $is_recorded Whether or not the current blog was recorded. * @param bool $no_activity Whether to skip recording an activity item for this blog creation. */ do_action_ref_array( 'bp_blogs_new_blog' , array ( & $recorded_blog , $is_private , $is_recorded , $no_activity ) ); } |
Changelog
Version | Description |
---|---|
BuddyPress 1.0.0 | Introduced. |
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.