Skip to:
Content
Pages
Categories
Search
Top
Bottom

Update custom table field when posting activity


  • buddycore
    Participant

    @buddycore

    I’d like to add an entry to a custom table when posting to the activity stream. How would I go about doing this? I have no idea at this stage.

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)

  • coffeywebdev
    Participant

    @coffeywebdev

    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


    buddycore
    Participant

    @buddycore

    Thanks a lot, that’s really helpful.


    buddycore
    Participant

    @buddycore

    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.


    danbp
    Moderator

    @danbp

    Hi @buddycore,

    have you checked BP’s Attachment API ?

    BP_Attachment


    buddycore
    Participant

    @buddycore

    @danbp thanks a lot, that’s brilliant. I will look at the sample plugin and try to work this out.


    Henry Wright
    Moderator

    @henrywright

    In order to update a custom table you’d need to use the wpdb class.

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar