Skip to:
Content
Pages
Categories
Search
Top
Bottom

Activity meta update and $activity_id

  • I’m on the verge of madness with this, it’s not funny.

    I want to add a field to the activity post form. I modified the form, global.js and bp_custom.php according to a post I found on the forum and it works, meaning the data is entered into the database BUT it always has the activity_id value 1. I tried anything I could find on the forums.

    Basically, the problem is $activity_id which is always 1. The rest seems to work.
    This is what i got in bp_custom.php:

    `function add_title_to_activity( $content, $user_id, $activity_id ) {
    bp_activity_update_meta( $activity_id, ‘title’, $_POST );
    }

    add_action( ‘bp_groups_posted_update’, ‘add_title_to_activity’, 10, 3 );`

    If anyone has any ideas as to why $activity_id doesn’t contain the actual id of the posted update, please help.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Unfortunately for me I haven’t managed to find a solution.

    Doesn’t anyone know how to get the id of the activity update in bp_custom.php?

    Any hints greatly appreciated.

    The activity ID is the 4th parameter!

    No, I’m afraid you didn’t understand. My problem is that the value of $activity_id is 1 with each and every posted update. This is just here in my function. The rest of the script is functioning correctly.

    So with the function from my first post the database entries from bp_activity_meta table look like this:

    id = “14”
    activity_id = “1” <<<
    meta_key = “title”
    meta_value = “Some Title Blah blah…”

    So on every new activity update there isn’t a new entry but just updates meta_value with whatever contains $_POST.

    Oh you mean it should be:

    `add_action( ‘bp_groups_posted_update’, ‘add_title_to_activity’, 10, 4 );`

    ?

    I tried that and it’s the same outcome.

    Yes, then add a 4th param to your function. Param 3 is the user id.

    Oooooohh!

    So I started blindly fiddling with the parameters and something worked :D
    I thought if $activity_id is the 4th parameter and have no idea what would be the 3rd one I passed a bogus parameter and what do you know… it worked.

    `function add_title_to_activity( $content, $user_id, $null, $activity_id ) {
    bp_activity_update_meta( $activity_id, ‘title’, $_POST );
    }

    add_action( ‘bp_groups_posted_update’, ‘add_title_to_activity’, 10, 4 );`

    Data get entered correctly into the db table but just to do things right… what are all the parameters of the functions?
    This is voodoo stuff to me really… :D

    Thanks Paul!

    Didn’t see your post…
    Anyway, honestly I have no idea why it works but I’m glad it does.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Activity meta update and $activity_id’ is closed to new replies.
Skip to toolbar