bp_xprofile_updated_profile_activity (intuser_id美元数组field_ids美元数组()保龄球美元的错误数组old_value美元数组()数组new_value美元数组()

当用户更新了他的配置文件时,添加一个活动项。

描述

参数

user_id美元

int(必需)更新了个人资料的用户ID。

field_ids美元

数组(可选)提交字段的id。

默认值:数组()

美元的错误

保龄球(可选)如果发生验证或保存错误,则为True,否则为false。

默认值:假

old_value美元

数组(可选)预保存xprofile字段值和可见性级别。

默认值:数组()

new_value美元

数组(可选)保存后的xprofile字段值和可见性级别。

默认值:数组()

返回

(保龄球)成功时真,失败时假。

文件:bp-xprofile / bp-xprofile-activity.php

function bp_xprofile_updated_profile_activity($user_id, $field_ids = array(), $errors = false, $old_values = array(), $new_values = array()){//如果有错误,不要发布。如果(!Empty ($errors)){返回false;} //如果activity组件不是活动的,则保释。如果(!Bp_is_active ('activity')){返回false;} //如果没有变化,或者变化只与非公共字段相关,则不要发布。美元public_changes = false;Foreach ($new_values as $field_id => $new_value) {$old_value = isset($old_values[$field_id]) ?$old_values[$field_id]: "; "; // Don't register changes to private fields. if ( empty( $new_value['visibility'] ) || ( 'public' !== $new_value['visibility'] ) ) { continue; } // Don't register if there have been no changes. if ( $new_value === $old_value ) { continue; } // Looks like we have public changes - no need to keep checking. $public_changes = true; break; } // Bail if no public changes. if ( empty( $public_changes ) ) { return false; } // Throttle to one activity of this type per 2 hours. $existing = bp_activity_get( array( 'max' => 1, 'filter' => array( 'user_id' => $user_id, 'object' => buddypress()->profile->id, 'action' => 'updated_profile', ), ) ); // Default throttle time is 2 hours. Filter to change (in seconds). if ( ! empty( $existing['activities'] ) ) { /** * Filters the throttle time, in seconds, used to prevent excessive activity posting. * * @since BuddyPress 2.0.0 * * @param int $value Throttle time, in seconds. */ $throttle_period = apply_filters( 'bp_xprofile_updated_profile_activity_throttle_time', HOUR_IN_SECONDS * 2 ); $then = strtotime( $existing['activities'][0]->date_recorded ); $now = bp_core_current_time( true, 'timestamp' ); // Bail if throttled. if ( ( $now - $then ) < $throttle_period ) { return false; } } // If we've reached this point, assemble and post the activity item. $profile_link = trailingslashit( bp_core_get_user_domain( $user_id ) . bp_get_profile_slug() ); return (bool) xprofile_record_activity( array( 'user_id' => $user_id, 'primary_link' => $profile_link, 'component' => buddypress()->profile->id, 'type' => 'updated_profile', ) ); }

更新日志

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

问题吗?

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