Skip to:
Content
Pages
Categories
Search
Top
Bottom

Modifying activity content


  • thomasbp
    Participant

    @thomasbp

    Hi,

    I’d like to modify the activity content before it is saved. In my case I want to attach an image placeholder to the wire activity entries.

    I’ve tried that below, but it does not work:

    add_action(‘bp_activity_add’, ‘sw_add_image_activity’,1)

    function sw_add_image_activity($activity) {

    $image = createImage();

    if($image === false) return $content;

    $image_link.= ‘ [‘.date(‘Y’).’|’.date(‘m’).’|’.str_replace(‘.jpg’,”, basename($image)).’]’;

    $activity[‘content’].= $image_link; //modifying activity stream

    return $activity;

    }

    Does anyone have an Idea what I do wrong? TiA

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

  • Andy Peatling
    Keymaster

    @apeatling

    Find the specific filter on wire activity posting and use that in your themes’ functions.php.


    thomasbp
    Participant

    @thomasbp

    Thx Andy,

    problem solved.

    My mistake was:

    I wanted to modify the the wire content and the activity content with two different functions. However, the activity entry is triggered by the wire save functions. Thus I had only to change the content before it’s processed by the wire functions and “forwarded” to the activity process. This is how I did it:

    Solution:

    add_action(‘bp_wire_post_content_before_save’, ‘sw_add_image_wire’,1);

    function sw_add_image_wire($message){

    $image = createImage();

    if($image === false) return $message;

    $image_link=”.date(‘Y’).’|’.date(‘m’).’|’.str_replace(‘.jpg’,”, basename($image)).”;

    $message.= $image_link;

    return $message;

    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Modifying activity content’ is closed to new replies.
Skip to toolbar