Skip to:
Content
Pages
Categories
Search
Top
Bottom

Gettinng id of the activity status

  • @dedurus

    Member

    Hi

    I’m trying to fetch the content data from wp_db_activity table in order to escape from HTML tags that are wrapped around the content. I need this since I want to implement an audio player for links to mp3 files.

    The `bp_activity_content_body()` gives me results like
    `http://link_to_mp3_file`
    while I need only the link
    `http: // link_to_mp3_file`
    without the markup for use in JavaScript.

    Using the following code in bp-themes/bp-default/activity/entry.php, I got only the activity ID, but cannot fetch the content data.

    `$content = $wpdb->get_results($wpdb->prepare(“SELECT content FROM $bp->activity->table_name WHERE id = %d” , bp_activity_id()));
    `

    I’m new to BuddyPress, and still learning the code, so any help would be great.

    Thanks in advance

Viewing 4 replies - 1 through 4 (of 4 total)
  • @r-a-y

    Keymaster

    Always use BP-native functions when you can.

    Use bp_activity_get_specific() (available in /bp-activity.php). It takes an activity ID as an argument.

    So you can do this:
    `
    // get activity
    $activity_get = bp_activity_get_specific( array( ‘activity_ids’ => YOURACTIVITYID ) );

    // single out the activity
    $activity = $activity_get[0];

    // grab specific activity item
    $activity_body = $activity->content;
    `

    @dedurus

    Member

    @r-a-y thanks for reply (i’m little late with mine).
    The problem is that I cannot determine the activity ID.
    In entry.php, i tried with bp_activity_id() function to wrap it in a query, but all I get is ID of the activity printed in the browser.
    How can I determine the activity ID in entry.php ?

    For example this code works (yet with native WP functions), but for static activity ID:

    $Fql = $wpdb->get_results($wpdb->prepare("SELECT * FROM {$bp->activity->table_name} WHERE id = %d", 35));

    Thanks

    @dedurus

    Member

    Seems that I found the solution to access individual activity ID, although not sure if this is a proper way to access it since I’m using “global $activities_template”.
    Here’s the code:

    `global $activities_template;
    //get single activity ID for loop in entry.php
    $act_ID = $activities_template->activity->id;
    // get activity
    $activity_get = bp_activity_get_specific( array( ‘activity_ids’ => $act_ID ) );
    // single out the activity
    $activity_single = $activity_get[0];
    $activity_body = $activity_single->content;`

    Thanks again

    @r-a-y

    Keymaster

    You can use bp_get_activity_id() instead of directly accessing the $bp global.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Gettinng id of the activity status’ is closed to new replies.
Skip to toolbar