bp_blogs_record_activity

Record blog-related activity to the activity stream.

Description

(int|bool) bp_blogs_record_activity( (string) $args = '' ); 

Returns (int|bool)

On success, returns the activity ID. False on failure.

Parameters (1)

0. $args — Optional. (string) => ''
The args.

Options

    ;        


    Usage

    1. if ( !function_exists( 'bp_blogs_record_activity' ) ) { 
    2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-blogs/bp-blogs-activity.php'; 
    3.  
    4. // The args. 
    5. $args = ''; 
    6.  
    7. // NOTICE! Understand what this does before running. 
    8. $result = bp_blogs_record_activity($args); 
    9.  

    Defined (1)

    The function is defined in the following location(s).

    /bp-blogs/bp-blogs-activity.php  
    1. function bp_blogs_record_activity( $args = '' ) { 
    2. $defaults = array( 
    3. 'user_id' => bp_loggedin_user_id(),  
    4. 'action' => '',  
    5. 'content' => '',  
    6. 'primary_link' => '',  
    7. 'component' =>buddypress)->blogs->id,  
    8. 'type' => false,  
    9. 'item_id' => false,  
    10. 'secondary_item_id' => false,  
    11. 'recorded_time' => bp_core_current_time(),  
    12. 'hide_sitewide' => false 
    13. ); 
    14.  
    15. $r = wp_parse_args( $args, $defaults ); 
    16.  
    17. if ( ! empty( $r['action'] ) ) { 
    18.  
    19. /** 
    20. * Filters the action associated with activity for activity stream. 
    21. * @since 1.2.0 
    22. * @param string $value Action for the activity stream. 
    23. */ 
    24. $r['action'] = apply_filters( 'bp_blogs_record_activity_action', $r['action'] ); 
    25.  
    26. if ( ! empty( $r['content'] ) ) { 
    27.  
    28. /** 
    29. * Filters the content associated with activity for activity stream. 
    30. * @since 1.2.0 
    31. * @param string $value Generated summary from content for the activity stream. 
    32. * @param string $value Content for the activity stream. 
    33. * @param array $r Array of arguments used for the activity stream item. 
    34. */ 
    35. $r['content'] = apply_filters( 'bp_blogs_record_activity_content', bp_activity_create_summary( $r['content'], $r ), $r['content'], $r ); 
    36.  
    37. // Check for an existing entry and update if one exists. 
    38. 'user_id' => $r['user_id'],  
    39. 'component' => $r['component'],  
    40. 'type' => $r['type'],  
    41. 'item_id' => $r['item_id'],  
    42. 'secondary_item_id' => $r['secondary_item_id'],  
    43. ) ); 
    44.  
    45. return bp_activity_add( array( 'id' => $id, 'user_id' => $r['user_id'], 'action' => $r['action'], 'content' => $r['content'], 'primary_link' => $r['primary_link'], 'component' => $r['component'], 'type' => $r['type'], 'item_id' => $r['item_id'], 'secondary_item_id' => $r['secondary_item_id'], 'recorded_time' => $r['recorded_time'], 'hide_sitewide' => $r['hide_sitewide'] ) );