Skip to content

Instantly share code, notes, and snippets.

View sbrajesh's full-sized avatar

Brajesh Singh sbrajesh

View GitHub Profile
@sbrajesh
sbrajesh / hide-subscribers.php
Last active March 14, 2024 23:27
Hide Subscriber Users from BuddyPress member Directory
add_action('bp_ajax_querystring','bpdev_exclude_users',20,2);
function bpdev_exclude_users($qs=false,$object=false){
//list of users to exclude
if($object!='members')//hide for members only
return $qs;
$excluded_user=join(',',bpdev_get_subscriber_user_ids());//comma separated ids of users whom you want to exclude
@sbrajesh
sbrajesh / remove-blogs-from-dir.php
Created May 25, 2012 22:44
Remove the blogs from Blog Dir list
<?php
add_action('bp_blogs_get_blogs','bpdev_exclude_blogs',20,2);
function bpdev_exclude_blogs($blogs_details=false,$params){
//list of users to exclude
$blogs=array();
$excluded_blogs=array(1,3);//comma separated ids of blogs whom you want to exclude
$selected_blogs=$blogs_details['blogs'];
@sbrajesh
sbrajesh / xprofile-data-on-admin-user-edit.php
Created May 30, 2012 23:11
Display Xprofile data in admin user-edit page
<?php
add_action('personal_options','bpdev_show_info_on_profile_edit_page');
function bpdev_show_info_on_profile_edit_page($user){
$user_id=$user->ID;
//repeat the below line for each of the field you want to list
//replace the field name with the xprofile field name e.g Name, About etc
?>
<tr><th>Field Name</th><td><?php echo xprofile_get_field_data('Field Name',$user_id);?></td></tr>
@sbrajesh
sbrajesh / propagate-comment-in-bp-multinetwork.php
Created May 31, 2012 22:34
Propagate comments recording from sub network to main site
<?php
add_action( 'comment_post', 'bpdev_record_comment_on_main_site', 20, 2 );
add_action( 'edit_comment', 'bpdev_record_comment_on_main_site', 20 );
function bpdev_record_comment_on_main_site($comment_id, $is_approved = true ) {
global $bp, $wpdb;
$blog_id = (int)$wpdb->blogid;
@sbrajesh
sbrajesh / propagate-post-activity-to-main-site.php
Created May 31, 2012 22:34
Propagate post recording to activity from sub site to main site
add_action('save_post','bpdev_record_post_on_main_site',20,2);
function bpdev_record_post_on_main_site($post_id, $post, $user_id = 0 ) {
global $bp, $wpdb;
$post_id = (int)$post_id;
$blog_id = (int)$wpdb->blogid;
if($blog_id==1)
return;//it is recording main site and we don't have to worry about it
switch_to_blog(1);//switch to main site
@sbrajesh
sbrajesh / global.js.patch
Created June 15, 2012 01:00
global.js patch
--- /var/www/bp/1.5/332test/wp-content/plugins/buddypress/bp-themes/bp-default/_inc/global.js
+++ /var/www/bp/1.5/332test/2933923/global.js
@@ -256,12 +256,16 @@
jq.cookie('bp-activity-oldestpage', 1, {path: '/'} );
var oldest_page = ( jq.cookie('bp-activity-oldestpage') * 1 ) + 1;
-
+ var search_terms=jq("#search-terms").val();
+ search_terms=search_terms?search_terms:'';
+
@sbrajesh
sbrajesh / personal-activity-default-on-activity-dir.diff
Created September 21, 2012 00:04
personal-activity-default-on-activity-dir
diff --git a/bp-themes/bp-default/_inc/global.js b/bp-themes/bp-default/_inc/global.js
index 9efbd71..fa8ecc8 100644
--- a/bp-themes/bp-default/_inc/global.js
+++ b/bp-themes/bp-default/_inc/global.js
@@ -1261,7 +1261,7 @@ function bp_filter_request( object, filter, scope, target, search_terms, page, e
search_terms = jq.query.get('s');
if ( null == scope )
- scope = 'all';
+ scope = 'personal';
@sbrajesh
sbrajesh / global-search-in-wp-adminbar.php
Created September 24, 2012 20:39
Use wordpress adminbar search form for global search
function remove_wp_adminbar_search_menu(){
//remove the search from from adminbar menu
remove_action('admin_bar_menu', 'wp_admin_bar_search_menu', 4 );
}
add_action('init','remove_wp_adminbar_search_menu');
function custom_admin_bar_search_menu( $wp_admin_bar ) {
if ( is_admin() )
return;
@sbrajesh
sbrajesh / filter-wp-fb-connect-uid
Created January 14, 2013 23:25
Use facebook uid saved by wp-fb-autoconnect with fbplus
add_filter('get_user_metadata','fbplus_filter_wpfb_id',10,4);
function fbplus_filter_wpfb_id($val, $object_id, $meta_key, $single){
if($meta_key!='fb_account_id')
return $val;
//if meta key is fb_account_id, we will need to fetchand see if there exists a facebook_uid
$val=get_user_meta($object_id,'facebook_uid',$single);
if(empty($val))
$val=null;
@sbrajesh
sbrajesh / bp-activity-wire-functions.php
Last active December 13, 2015 17:39
BuddyPress Activity as wire
add_action('init', 'bdev_fix_activity_posting_hooks');
function bdev_fix_activity_posting_hooks() {
remove_action('wp_ajax_post_update', 'bp_dtheme_post_update');
}
//add our own handler for activity posting
add_action('wp_ajax_post_update', 'bp_mytheme_post_update');