Skip to:
Content
Pages
Categories
Search
Top
Bottom

Activity id for add meta to activity


  • dperezac2
    Participant

    @dperezac2

    Hello, I am trying to add some meta info to a new activity that is being created. For that I use the bp_acitivy_add hook, but I can not figure out how get the id of the activity that is being created. I used bp_get_activity_id() but it doesn’t work, but if I put a random integer it works.

    function my_acitivity_meta(){
    
        bp_activity_add_meta(bp_get_activity_id() , 'metaKey', 'metaValue' );
    
    }
    add_action('bp_activity_add', 'my_activity_meta');

    There is a way to get the id of the activity that is being created?.

    Thank You.

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

  • Michael
    Participant

    @mgparisi

    Ive got the same question… hmmm.


    shanebp
    Moderator

    @shanebp

    Did you try looking at the bp_activity_add function ?

    The activity id is the second variable passed in the action hook.
    Untested, but try:

    function my_activity_meta( $r, $id ){
    
        bp_activity_add_meta( $id, 'metaKey', 'metaValue' );
    
    }
    add_action('bp_activity_add', 'my_activity_meta', 20, 2);
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar