Skip to:

Filter activity stream by oembed

  • Hi,

    I have searched for this and couldn’t find an answer so I thought I’d ask here.

    Activity stream can be searched by a number of parameters, but it can’t be searched for for oembed data (

    OEmbed data seems to be treated as simple html (once parsed) and no flag is set in db to indicate that this indeed is oembed data (from what I have been able to find at least).

    Is there a way I can filter activity stream for oembeds so that for example I can put in a new tab next to my activity, friends, groups that’s called for example “videos”?

    Thanks in advance,


Viewing 5 replies - 1 through 5 (of 5 total)
  • I don’t think so. @r-a-y may know if it’s do-able.

    Hopefully @r-a-y looks at this. I don’t mind coding my own solution, just that I am not sure where the smartest place to hook into is.

    I can see parse_oembed is only called from bp-core-classes.php in the shortcode function and this is what confuses me…

    Avatar of r-a-y


    It’s doable, @dnxpert and @djpaul.

    When there’s an oEmbed item in the activity stream, there’s usually some accompanying meta saved in the activity meta table.

    You’ll want to hook into the filters available in BP_Activity_Activity::get() (located in /bp-activitiy/bp-activity-classes.php)

    Specifically, you’ll want to do a LEFT JOIN with the activity meta table (wp_bp_activity_meta) and do a search for “meta_key” that beings with “_oembed_”.

    If I can get myself around to it, it will be in my oft-delayed oEmbed plugin update.

    @r-a-y thanks very much!

    For anyone that goes looking for this in the future here is something I threw together – it should be a good starting point.

    If you put what’s below in your functions file, your activity wall will only show _oembed_ activity.

    add_filter( ‘bp_activity_get_user_join_filter’, ‘videos_filter_sql’, 10, 6 );
    add_filter( ‘bp_activity_total_activities_sql’, ‘videos_filter_sql_count’, 10, 3 );

    function videos_filter_sql_count( $sql, $where_sql, $sort ) {
    global $bp, $wpdb;

    if ( !empty( $bp->loggedin_user->is_super_admin ) && $bp->loggedin_user->is_super_admin )
    return $sql;

    $sql = $wpdb->prepare( “SELECT count( FROM {$bp->activity->table_name} a
    LEFT JOIN {$bp->activity->table_name_meta} m ON m.activity_id = {$where_sql} AND (m.meta_key REGEXP ‘^_oembed_’) ORDER BY a.date_recorded {$sort}” );
    return $sql;

    function videos_filter_sql( $sql, $select_sql, $from_sql, $where_sql, $sort, $pag_sql=” ) {
    global $bp, $wpdb;

    if ( !empty( $bp->loggedin_user->is_super_admin ) && $bp->loggedin_user->is_super_admin )
    return $sql;

    $from_sql .= ” LEFT JOIN {$bp->activity->table_name_meta} m ON m.activity_id =”;
    $where_sql .= $wpdb->prepare( ” AND (m.meta_key REGEXP ‘^_oembed_’)” );

    if ( !empty( $pag_sql ) )
    $sql = $wpdb->prepare( “{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort} {$pag_sql}” );
    $sql = $wpdb->prepare( “{$select_sql} {$from_sql} {$where_sql} ORDER BY a.date_recorded {$sort}” );

    return $sql;

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

You must be logged in to reply to this topic.