You want to add a ‘Personal’ option to the ‘Show’ selector on Site Wide Activity?
Try this in your theme/functions.php or in bp-custom.php
function leanne_activity_filter_options() {
if ( is_user_logged_in() )
echo '<option value="personal">Personal</option>';
}
add_action( 'bp_activity_filter_options', 'leanne_activity_filter_options' );
function leanne_ajax_querystring( $query_string, $object ) {
if ( 'activity' != $object )
return $query_string;
if ( ! bp_is_activity_directory() )
return $query_string;
$query_args = wp_parse_args( $query_string, array() );
$page = $query_args['page'];
if( isset( $query_args['action'] ) && $query_args['action'] == 'personal' ) {
$query_args = array();
$query_args['page'] = $page;
$query_args['user_id'] = bp_loggedin_user_id();
$query_string = http_build_query( $query_args );
}
return $query_string;
}
add_filter( 'bp_ajax_querystring', 'leanne_ajax_querystring', 20, 2 );
That’s great, thanks!
Unfortunately the theme Im using has two sets of filters; one set of filters is listed across the top with ‘All Members’, ‘Friends’, ‘Favorites’, ‘mentions’. This is where I want to add ‘Personal’. Then there is another filter in the form of a drop down which has ‘new members’, ‘posts’, ‘comments’ etc which is where your code has placed the ‘personal’ filter option.
This is the code I currently have in activity/index.php:
<li id="activity-me"> <a id="just-me" href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() ?>">Personal</a>
Is it easy to adjust the code above so that it uses the code you have supplied to add the correct ajax filter? Ive tried playing around with your code but had no joy getting it to work.
Many thanks for your help.
This is separate from the function I supplied.
Put it in activity/index.php
<li id="activity-just-me"> <a id="just-me" href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() . '/'; ?>">Personal</a></li>
You can also insert the link without using a template overload by using the provided hook:
do_action( 'bp_activity_type_tabs' );
Seriously? All I was missing was the ‘/’; ?
Thanks so much for your help.