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
View mpp-limit-gallery-media-by-user.php
@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 / mpp-bp-reshare.php
Created May 30, 2017
MediaPress media support for BP reshare plugin
View mpp-bp-reshare.php
// For reshare, add mpp_media_upload type.
add_filter( 'buddyreshare_activity_types', function( $types ) {
$types[] = 'mpp_media_upload';
return $types;
});
// Filter the action string for the shared media activity
add_filter( 'buddyreshare_prepare_reshare_activity', function( $action_string, $activity ) {
if ( 'mpp_media_upload' !== $activity->type ) {
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 / mpp-display-gallery-media-owner-name.php
Created Jan 28, 2017
Add the gallery creator and media uploaders name to mediapress gallery/media.
View mpp-display-gallery-media-owner-name.php
@sbrajesh
sbrajesh / copy-png-files.php
Created Aug 17, 2016
Copy png files from the directory recursively to the destination directory
View copy-png-files.php
<?php
/** Copy PNG files from the Source Directory( and its child directories) to destination as specified
*
* I use it to move all the png files from the extracted subtle patterns directories to another directory
*
* @param string $path the directory which contains our subdirectories
* @param string $destination_dir the absolute path to directory where files will be moved
*/
function copy_png_files( $path, $destination_dir ) {
@sbrajesh
sbrajesh / jaume-group-open-close.php
Created Jul 27, 2016
group open close example for Jaume
View jaume-group-open-close.php
//do not let the activity be posted by any means(do not allow from directory etc)
function bd_check_post_update() {
$item_id = 0;
$object = '';
View buddypress-stop-group-join-notifications.php
//Do not notify for join group activity in BP Local group Activity notifier
function buddydev_do_not_notify_join_group_activity( $stop_notification, $activity ) {
if ( $activity->type == 'joined_group' ) {
$stop_notification = true;
}
return $stop_notification;
}
add_filter( 'bp_local_group_notifier_skip_notification', 'buddydev_do_not_notify_join_group_activity', 10, 2 );
View skipp-local-notification.php
function buddydev_skip_group_join_notification( $skip, $activity ) {
if ( $activity->type == 'joined_group' ) {
$skip = true;
}
return $skip;
}
add_filter( 'bp_local_group_notifier_skip_notification', 'buddydev_skip_group_join_notification', 10, 2 );
@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.