Skip to content

Instantly share code, notes, and snippets.

Brajesh Singh sbrajesh

Block or report user

Report or block sbrajesh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sbrajesh
sbrajesh / Community activity as Default
Created Jun 15, 2011
It will make the community activity sub tab as default activity tab on profile
View Community activity as Default
//fix the nav default
function bpcom_fix_nav(){
global $bp;
if(!bp_is_my_profile())
return;
if ( $bp->current_component == BP_ACTIVITY_SLUG && $bp->current_action=="just-me" ) {
$action=bpcom_get_current_actual_action();
@sbrajesh
sbrajesh / Allow Developers to Use their own custom css for background positioning etc
Created Jun 19, 2011
Allow Developers to Use their own custom css for background positioning etc
View Allow Developers to Use their own custom css for background positioning etc
<?php
add_filter("bppg_iwilldo_it_myself","__return_true");//stop the plugin to inject css
//now we can write our own css
add_action("wp_head","my_css_for_profile_bg");
function my_css_for_profile_bg(){
$image_url=bppg_get_image();
if(!$image_url)
@sbrajesh
sbrajesh / Allow to change the background of profile container div
Created Jun 19, 2011
Allow to change the background of profile container div
View Allow to change the background of profile container div
<?php
add_filter("bppg_iwilldo_it_myself","__return_true");//stop the plugin to inject css
//now we can write our own css
add_action("wp_head","my_css_for_profile_bg");
function my_css_for_profile_bg(){
$image_url=bppg_get_image();
if(!$image_url)
@sbrajesh
sbrajesh / css mod for Jeremy
Created Jun 28, 2011
modification of Background css for Jeremy
View css mod for Jeremy
<?php
add_filter("bppg_iwilldo_it_myself","__return_true");//stop the plugin to inject css
//now we can write our own css
add_action("wp_head","my_css_for_profile_bg");
function my_css_for_profile_bg(){
$image_url=bppg_get_image();
if(!$image_url)
@sbrajesh
sbrajesh / redirect to Profile
Created Jul 3, 2011
Redirect to Profile for admin
View redirect to Profile
<?php
/*
Plugin Name: BP Redirect to Profile for Buddypress
Description:Redirect user to their profile when they login
Version: 1.1.1
Requires at least: BuddyPress 1.1
Tested up to: BuddyPress 1.2.8+WordPress 3.1
License: GNU General Public License 2.0 (GPL) http://www.gnu.org/licenses/gpl.html
Author: Brajesh Singh
Author URI: http://buddydev.com
@sbrajesh
sbrajesh / Create activity entry on profile background upload
Created Jul 6, 2011
Create activity entry on profile background upload
View Create activity entry on profile background upload
add_action("bppg_background_uploaded","bppg_record_activity");
function bppg_record_activity( $bg_image ) {
global $bp;
if ( !function_exists( 'bp_activity_add' ) )
return false;
$r = array(
'user_id' => $bp->loggedin_user->id,
'content' =>false ,
'action'=>sprintf("%s changed their profile background",bp_core_get_userlink( $bp->loggedin_user->id )),
View Redirect non logged in users to something
//redirect non logged in users to homepage
function bp_guest_redirect() {
global $bp;
if(!is_user_logged_in()&&!(bp_is_page(BP_REGISTER_SLUG)||bp_is_page(BP_ACTIVATION_SLUG)||is_front_page())) { // not logged in user
wp_safe_redirect( bp_get_root_domain());//make sure page exists exist slug welcome
exit(0);//no further execution
}
}
@sbrajesh
sbrajesh / recent-visitor-show-to-every-one
Created Aug 3, 2011
Show recent Visitor to everyone
View recent-visitor-show-to-every-one
remove_action("bp_after_member_header","visitors_show_my_recent_visitor");//remove hook
add_action("bp_after_member_header","visitors_show_everyone_recent_visitor");//add custom view
function visitors_show_everyone_recent_visitor(){
global $bp;
$recent_visitors=visitors_get_recent_visitors();
if(empty($recent_visitors))
return;//if no visists yest, do not show at all
@sbrajesh
sbrajesh / xprofile-enhance
Created Sep 4, 2011
functions to show the field data or ask to fill it
View xprofile-enhance
//pass the field name as string
function show_or_ask_to_fill($field_name){
$data= xprofile_get_field_data($field_name, bp_loggedin_user_id());
if(empty($data)){
$field_id=xprofile_get_field_id_from_name($field_name);
$group_id=custom_get_group_from_field($field_id);
echo sprintf("Please click <a href='%s'>%s</a> to fill the data", bp_get_loggedin_user_link()."profile/edit/group/".$group_id."/#field_".$field_id,$field_name);
}
@sbrajesh
sbrajesh / bpdev_get_age_from_dob
Created Oct 2, 2011
Get Age from BuddyPress datebox field data
View bpdev_get_age_from_dob
/**
* Get Age from BuddyPress date of Birth
* @param string $dob_field_name :name of the DOB field in xprofile, like Dob or Date of Birth
* @param int $user_id : the user for which you want to retrieve the age
* @param string $format: the way you want to print the difference, look t <http://php.net/manual/en/dateinterval.format.php> for the acceptable agrs
* @return string :the formatted age in year/month
*/
function bpdev_get_age_from_dob($dob_field_name,$user_id=false,$format="%y Years, %m Month(s), %d days"){
if(!$user_id)
You can’t perform that action at this time.