Modifying BP Class output with an add_action function
-
I have been developing this plugin for a while now, and was actually running until the new version of BP came out, then alot of thins broke. But mostly it was my poor coding. I hard coded changes in BP and on upgrade VOILA!! I knew that. So anyway moving on and getting alot better at WP and BP plugin development. I have made my plugins more BP and WP aware when possible and also theme aware.
I am trying to slightly modify the out put of the bp_has_groups template tag by adding an extra SQL query to the BP_Groups_Groups:get_active function. I have easily modified out put of functions outside the BP Objected Oriented classes with “add_action” But I am having difficulty doing the same for functions called inside the BP classes.
currently (and this works) I have the coded appended to the bottom of the get_active function
` if ( $bp->current_component == $bp->schools->slug && !empty($bp->current_action ) && !empty($bp->action_variables[0] ) && !empty($bp->action_variables[1] ) ){$browse_sql = “AND m.city_id = ‘$city_id'”;
$paged_groups = $wpdb->get_results( “SELECT g.*, gm1.meta_value as total_member_count, gm2.meta_value as last_activity FROM {$bp->groups->table_name_groupmeta} gm1, {$bp->groups->table_name_groupmeta} gm2, {$bp->schools->table_name} m, {$bp->groups->table_name} g WHERE g.id = m.group_id AND g.id = gm1.group_id AND g.id = gm2.group_id AND gm2.meta_key = ‘last_activity’ AND gm1.meta_key = ‘total_member_count’ {$browse_sql} {$hidden_sql} {$search_sql} ORDER BY last_activity DESC {$pag_sql}” );
$total_groups = $wpdb->get_var( “SELECT COUNT(DISTINCT m.group_id) FROM {$bp->schools->table_name} m LEFT JOIN {$bp->groups->table_name_groupmeta} gm ON m.group_id = gm.group_id INNER JOIN {$bp->groups->table_name} g ON m.group_id = g.id WHERE gm.meta_key = ‘last_activity’ {$browse_sql} {$hidden_sql} {$search_sql} ” );}`
On future upgrades this little line will be overwritten (I have a handy dandy copy to put it right back) but I’d rather not especially if I will be releasing this to the public.
I would like some help in getting this into a function and calling that function using the
`add_action( $tag, $function_to_add, $priority, $accepted_args );`From the W Codex
$function_to_add
(callback) (required) The name of the function you wish to be called. Note: any of the syntaxes explained in the PHP documentation for the ‘callback’ type are valid.
Default: NoneAm hoping @travel-junkie cna check this out, he’s been a great help before. Any help is appreciated
- The topic ‘Modifying BP Class output with an add_action function’ is closed to new replies.