You could hook into the bp_activity_add
action like this:
function bp_plugin_hook_activity_add( $activity ) {
// insert code to be executed when activity is created
// read the link below for more code examples
}
add_action( 'bp_activity_add', 'bp_plugin_hook_activity_add', 10, 1 );
You can access the activity variables like this:
$activity[‘type’] or $activity[‘content’]
you should be able to use any of the keys below:
id
action
content
component
type
primary_link
user_id
item_id
secondary_item_id
recorded_time
hide_sitewide
is_spam
For more reading check out this link:
Posting Activity from Plugins
Thanks a lot, that’s really helpful.
An update on this, and help required.
I’m trying to attach a file upload, but this hook doesn’t let me return the $_FILES array for some reason.
I have updated post-form.php to have an enctype
of multipart/form-data
but when I run my function onto bp_activity_add
no data is in the $_FILES
array.
Any ideas? I’m kinda stuck here.
Hi @buddycore,
have you checked BP’s Attachment API ?
BP_Attachment
@danbp thanks a lot, that’s brilliant. I will look at the sample plugin and try to work this out.
In order to update a custom table you’d need to use the wpdb class.