Skip to:
Content
Pages
Categories
Search
Top
Bottom

sprucing up activity items


  • jazgold
    Participant

    @jazgold

    ( BP 1.1.1 )

    so basically i want different types of content to appear differently in the sitewide feed. i have types that are albums, or events… etc. implemented through more-fields.

    when a user posts “an album,” it makes sense to show a couple of image thumbs, right?

    i’m getting there, but i have a couple of questions.

    currently, i’m hooking into bp_activity_add, and simply modifying the content of the row right after it’s been updated. accessing the right row in the database cannot be done directly because the ID of the activity row that was added/modified is not passed as one of the 7 arguments.

    so what i’m doing is querying for it based on matching all the arguments that i do have, but unfortunately there’s always the possibility that i could match the wrong row. (it’d be nice if the ID were simply there:)

    $query = "SELECT id FROM wp_bp_activity_user_activity_cached WHERE ";
    $query .= "user_id=".$args['user_id'];
    $query .= " AND component_name='". $args['component_name']."'";
    $query .= " AND component_action='". $args['component_action']."'";
    //$query .= " AND content='". $args['content']."'";
    $query .= " AND primary_link='". $args['primary_link']."'";
    $query .= " AND item_id='". $args['item_id']."'";
    $query .= " AND secondary_item_id='".$args['secondary_item_id']."'";
    //$query .= " AND date_recorded='". $args['date_recorded']."'";
    $query .= "ORDER BY id DESC";

    $activity = $wpdb->get_row( $query );

    it will return only one row, and because i’m sorting by ID and DESC, i should have the newest. it should be fine.

    the actual questions:

    but if you notice i’ve commented out content and date recorded. the first is content which simply does not match, and i’m assuming it’s because i’m not encoding. the second is the date recorded, and i’m not sure why, but that argument is being passed to the my hooked function as an empty string. it’s certainly not empty in the database – any ideas why?

    in case anyone’s curious, after the code above, if it’s referencing a blog post, it looks for its image attachments (via the “item_id”)… then we can insert HTML for those little thumbs into the content field of the activity row… which i’m just overwriting entirely.

Viewing 3 replies - 1 through 3 (of 3 total)
  • I haven’t time to dig through answers for your questions, but if you’ve updated or replaced a record, you can get the ID immediately afterwards via $wpdb->insert_id.


    jazgold
    Participant

    @jazgold

    the other questions are not really that important right now.

    because, man,

    that is much, much sexier

    thanks DJPaul for pointing out it’s sitting right there in $wpdb

    :D I only discovered it recently too!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘sprucing up activity items’ is closed to new replies.
Skip to toolbar