WordCamp Europe 2013
wp_posts
wp_comments
wp_users
wp_posts
(CPT)wp_bp_groups
wp_bp_friends
wp_rg_lead
http://teleogistic.net/feed
GET https://api.twitter.com/1.1/statuses/
user_timeline.json?screen_name=boone&count=20
GET https://api.yourmom.com/1.0/
wceu-attendees-moms?fields=phone
Show me all of Boone's activity
$sql = "SELECT {$all_the_things}
FROM {$all_the_places}
WHERE {$the_user_index} = {$boones_user_id}
ORDER BY {$omg_wtf} DESC;"
bp-activity
provides:
mysql > DESCRIBE wp_bp_activity;
id | bigint(20)
user_id | bigint(20)
component | varchar(75)
type | varchar(75)
action | text
content | longtext
primary_link | varchar(255)
item_id | bigint(20)
secondary_item_id | bigint(20)
date_recorded | datetime
hide_sitewide | tinyint(1)
mptt_left | int(11)
mptt_right | int(11)
is_spam | tinyint(1)
user_id
is the user id
content
is the content
action
is an HTML string of the form "Boone posted a new comment on the post 'Foo'"
component
and
type
are non-localized strings that allow categorization and sorting
component
(eg 'groups'
) is more general than type
(eg 'joined_group'
item_id
and
secondary_item_id
are integer values representing relationships with arbitrary items
Example: Group creation
user_id
2
(Boone's user id)action
'<a href="http://example.com/members/boone/" title="Boone Gorges">Boone Gorges</a> created the group <a href="http://example.com/groups/smurfs/">Smurfs</a>'
content
''
component
'groups'
type
'created_group'
item_id
31
(the id of the Smurfs group)secondary_item_id
0
Example: Blog post
user_id
2
(Boone's user id)action
<a href="http://example.com/members/admin/" title="Boone Gorges">Boone Gorges</a> wrote a new post, [...]'
content
'This weekend, I am attending WordCamp Europe. It is the bomb. [...]'
component
'blogs'
type
'new_blog_post'
item_id
6
(the id of the Foo 6 site)secondary_item_id
13
(the id of the post)
$activity_id = bp_activity_add( array(
'action' => 'Boone wrote a new Twilight
fanfic, Vampire Luv',
'component' => 'fanfic',
'type' => 'new_fanfic',
'primary_link' => 'http://example.com/fanfic/vampire-luv',
'user_id' => $user_id,
'item_id' => $item_id, // The numeric id of the fanfic object
) );
Pass an 'id'
to update an existing item.
// Know the id?
$deleted = bp_activity_delete( array( 'id' => $activity_id, ) );
// Otherwise provide some specifics, and let BP find it
$deleted = bp_activity_delete( array(
'component' => 'fanfic',
'type' => 'new_fanfic',
'user_id' => $user_id,
'item_id' => $item_id, // The numeric id of the fanfic object
) );
// By user id
$activities = bp_activity_get( array(
'page' => 1,
'per_page' => 5,
'filter' => array(
'user_id' => $user_id,
),
) );
// By type and item_id
$activities = bp_activity_get( array(
// ...
'filter' => array(
'action' => 'new_fanfic',
'primary_id' => $fanfic_item_id,
),
) );
bp_activity_get()
meta_query
exclude
in
filter: user_id
filter: object
filter: action
filter: primary_id
filter: secondary_id
core.trac.wordpress.org
(Trac)[plugins|themes].trac.wordpress.org
(Trac)make.wordpress.org
(WordPress)wordpress.org/support
(bbPress 1.x)wordpress.org/[plugins|themes]
(bbPress 1.x)POST
request to a WP APIbp_activity_add()
$user = get_user_by('login', $_POST['user']);
if ( $_POST['newTopic'] ) {
$action = 'Created a new topic in Support Forums';
$content = $_POST['title'];
$type = 'new_topic';
} else {
$action = 'Posted a reply to ' . $_POST['title'] . ' in Support Forums';
$content = $_POST['message'];
$type = 'new_post';
}
$args = array(
'user_id' => $user->ID,
'action' => $action,
'content' => $content,
'primary_link' => $_POST['url'],
'component' => 'dotorg_activities',
'type' => $type,
'item_id' => $user->ID,
'secondary_item_id' => $_POST['topic'],
'hide_sitewide' => false
);
bp_activity_add( $args );
http://codex.buddypress.org/developer/function-examples/bp_activity_add/
http://codex.buddypress.org/developer/loops-reference/the-activity-stream-loop/