| 71 | | if ( (int)$_POST['group'] ) { |
| 72 | | $activity_id = groups_post_update( array( |
| 73 | | 'content' => $_POST['content'], |
| 74 | | 'group_id' => $_POST['group'] |
| 75 | | )); |
| 76 | | } else { |
| 77 | | $activity_id = bp_activity_post_update( array( |
| 78 | | 'content' => $_POST['content'] |
| 79 | | )); |
| | 71 | /* Allow item_id and component to be filtered */ |
| | 72 | $item_id = apply_filters( 'bp_dtheme_post_update_item_id', $item_id ); |
| | 73 | $component = apply_filters( 'bp_dtheme_post_update_component', $component ); |
| | 74 | |
| | 75 | switch ( $component ) { |
| | 76 | case $bp->profile->id : |
| | 77 | $activity_id = bp_activity_post_update( array( |
| | 78 | 'content' => $_POST['content'] |
| | 79 | )); |
| | 80 | break; |
| | 81 | |
| | 82 | case $bp->groups->id : |
| | 83 | $activity_id = groups_post_update( array( |
| | 84 | 'content' => $_POST['content'], |
| | 85 | 'group_id' => $_POST['group'] |
| | 86 | )); |
| | 87 | break; |
| | 88 | |
| | 89 | default: |
| | 90 | $activity_id = apply_filters( 'bp_custom_activity_update', $item_id, $component, $_POST['content'], $_POST['group'] ); |
| | 91 | break; |
| | 107 | /* Filters for default core components that support activity updates */ |
| | 108 | function bp_dtheme_profile_post_update_item_id( $item_id ) { |
| | 109 | if ( !(int)$_POST['group'] ) |
| | 110 | return $bp->loggedin_user->id; |
| | 111 | } |
| | 112 | add_filter( 'bp_dtheme_post_update_item_id', 'bp_dtheme_profile_post_update_item_id' ); |
| | 113 | |
| | 114 | function bp_dtheme_profile_post_update_component( $component ) { |
| | 115 | if ( !(int)$_POST['group'] ) |
| | 116 | return $bp->profile->id; |
| | 117 | } |
| | 118 | add_filter( 'bp_dtheme_post_update_component', 'bp_dtheme_profile_post_update_component' ); |
| | 119 | |
| | 120 | function bp_dtheme_groups_post_update_item_id( $item_id ) { |
| | 121 | if ( (int)$_POST['group'] ) |
| | 122 | return $_POST['group']; |
| | 123 | } |
| | 124 | add_filter( 'bp_dtheme_post_update_item_id', 'bp_dtheme_groups_post_update_item_id' ); |
| | 125 | |
| | 126 | function bp_dtheme_groups_post_update_component( $component ) { |
| | 127 | if ( (int)$_POST['group'] ) |
| | 128 | return $bp->groups->id; |
| | 129 | } |
| | 130 | add_filter( 'bp_dtheme_post_update_item_id', 'bp_dtheme_groups_post_update_component' ); |
| | 131 | |