修改buddypress的数据库前缀
2022年3月17日分类:未分类
function wpeve_change_table_prefix( $prefix ) {
$prefix='wp_';
return $prefix;
}
add_filter( 'bp_core_get_table_prefix', 'wpeve
_change_table_prefix', 10,1 );
2022年3月17日分类:未分类
function wpeve_change_table_prefix( $prefix ) {
$prefix='wp_';
return $prefix;
}
add_filter( 'bp_core_get_table_prefix', 'wpeve
_change_table_prefix', 10,1 );
2021年7月25日分类:未分类
BuddyPress作为Wordpress的重要社交插件,提供了用户系统,动态,群组,通知,消息等社交软件的基础功能。其中动态功能属于社交软件中必不可少的组成部分。
在BuddyPress相关数据表中,bp_activity和bp_activity_meta两张表负责了动态功能的数据存储。BuddyPress和WordPress一样,都采用了主表(bp_activity-BuddyPress,posts-WordPress),辅助表(bp_activity_meta-BuddyPress,postmeta-WordPress)的结构,bp_activity存储动态内容的相关信息,wp_activity_meta存储与动态内容相关联的一些信息。
我们先来看看两张表的字段(这里我们只介绍主要的字段)。
bp_activity的字段有action,component,content,is_spam,item_id
bp_activity_meta的字段比较少,与postmeta表一样,activity_id,meta_key,meta_value。这里不做具体介绍,从字面意思就可以看出,meta_key存键,meta_value为键值。比如动态中的收藏功能的meta_key为favorite_count。
在BuddyPress中添加新动态的功能函数是bp_activity_add()
用法:
$activity_id
= bp_activity_add( $args
);
参数:
$args
An array that describes the activity item that you’re creating. Possible values:
'id'
'action'
'<a href="http://example.com/members/bill">Bill</a> created the group <a href="http://example.com/groups/tmnt">TMNT</a>'
'content'
'component'
'type'
'component'
. For example, when creating a group, BuddyPress posts an activity item with the component ‘groups’ and the type ‘created_group’. 'type'
is used for filtering, as in the “New Groups”, “New Blog Posts”, etc dropdown on Activity directories.'primary_link'
'user_id'
0
for items that may be associated with no user at all.'item_id'
'item_id'
to the numeric id of the newly created group. This value can be used for filtering.'secondary_item_id'
'item_id'
to the ID of the blog, and the 'secondary_item_id'
to the ID of the comment.'recorded_time'
date( 'Y-m-d H:i:s', $time )
.) Defaults to the current time.'hide_sitewide'
'hide_sitewide'
is used in a few different ways:'user_id'
set to the user who sent the request and 'item_id'
set to recipient, and the other one vice versa. We need both items so that both users see the item on their own profiles, but it’s not desirable to see both of them on the sitewide stream, so the second one is marked 'hide_sitewide' => true
.'hide_sitewide'
is set to false
. Then, when viewing the group’s activity stream (which is accessible only to members), BP includes 'hide_sitewide'
items; in contrast, the sitewide stream excludes these items.'hide_sitewide'
is used simultaneously for preventing duplicates and for privacy. Please be sure you understand the way that 'hide_sitewide'
works before attempting to use it for the purposes of privacy in your own plugins.'is_spam'
true
to mark an item as spam.New database row activity ID
bp_activity_add()
is located in bp-activity/bp-activity-functions.php