bp_blogs_record_blog (intblog_id美元intuser_id美元保龄球no_activity美元

让BuddyPress知道一个新网站,这样它就可以跟踪它的活动。

描述

参数

blog_id美元

int(必需)被记录的博客ID。

user_id美元

int(必需)记录博客的用户ID。

no_activity美元

保龄球(可选)是否跳过记录有关此博客创建的活动项。默认值:false。

默认值:假

返回

(假|空)失败时返回false。

文件:bp-blogs / bp-blogs-functions.php

函数bp_blogs_record_blog($blog_id, $user_id, $no_activity = false) {if (empty($user_id)) $user_id = bp_loggedin_user_id();//如果blog是不可记录的,不要记录这个活动。如果(!bp_blogs_is_blog_recordable($blog_id, $user_id))返回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');$blog_id = 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 ) ); }

更新日志

更新日志
版本 描述
BuddyPress 1.0.0 介绍了。

问题吗?

我们总是很乐意帮助您解决代码或其他问题!搜索我们的开发人员文档联络支持,或与我们联系销售团队