1

I would like to create an post-based contextual activity stream to create an activity that is related to the post where we wrote it, I almost done. I’m using a shortcode on the function.php to show the activity stream by specifying that primary_id is equal to get_the_id() and for now it works but only not dynamically by manually editing in the bp-activity-function.php file the function bp_activity_add() and assigning to item_id the id of an article. And in this post, I’ve my contextual activity stream.

I am stuck because I can not dynamically get the id value of the article from which the activity is created. I have tried many solutions like using get_the_id() in the page bp-activity-function.php but the post_id is always 0 or null.

Do you have an idea ? Thanks !

function.php with the shortcode

echo do_shortcode ('[tabs][tab title="Les questions des Grands Explorateurs" start=open]'.'[activity-stream allow_posting=1 action=activity_update,mpp_media_upload primary_id='.get_the_ID().']'.'[/tab][tab title="Les réactions des explorateurs en herbe"]'.$comment_output.'[/tab][/tabs]');

bp-activity-functions.php page

function bp_activity_add( $args = '' ) {
    $r = bp_parse_args( $args, array(
        'id'                => false,                  // Pass an existing activity ID to update an existing entry.
        'action'            => '',                     // The activity action - e.g. "Jon Doe posted an update"
        'content'           => '',                     // Optional: The content of the activity item e.g. "BuddyPress is awesome guys!"
        'component'         => false,                  // The name/ID of the component e.g. groups, profile, mycomponent.
        'type'              => false,                  // The activity type e.g. activity_update, profile_updated.
        'primary_link'      => '',                     // Optional: The primary URL for this item in RSS feeds (defaults to activity permalink).
        'user_id'           => bp_loggedin_user_id(),  // Optional: The user to record the activity for, can be false if this activity is not for a user.
        'item_id'           => '',                  // Optional: The ID of the specific item being recorded, e.g. a blog_id. if item_id is update with a post_id, my activity stream is working
        'secondary_item_id' => false,                  // Optional: A second ID used to further filter e.g. a comment_id.
        ...
    ), 'activity_add' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.