Skip to content

Instantly share code, notes, and snippets.

View sbrajesh's full-sized avatar

Brajesh Singh sbrajesh

View GitHub Profile
@sbrajesh
sbrajesh / gist:e10452da07ab0a68b1cf457b87a3ec66
Created June 17, 2018 20:05
Set User account inactive when they verify/activate their BuddyPress Account
/**
* Mark account status as inactive when they activate their BuddyPress account after signup.
*
* @param int $user_id user id.
*/
function buddydev_custom_keep_user_inactive( $user_id ) {
if ( ! function_exists( 'bp_account_deactivator' ) ) {
return;
}
@sbrajesh
sbrajesh / xprofile-enhance
Created September 4, 2011 20:55
functions to show the field data or ask to fill it
//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 / wordpress-latest-post-content-fetch.php
Last active May 13, 2018 18:57
Efficient WordPress Latest Post content fetch for a user
/**
* Fetch of Latest Post content of a user by post type.
*
* @param array $atts shortcode atts.
* @param string $content n/a
*
* @return mixed|string
*/
function buddydev_user_last_post_shortcode( $atts, $content = '' ) {
@sbrajesh
sbrajesh / buddydev-bp-bradcrumb.php
Created March 22, 2018 02:14
Add breadcrumb trail compatibility for BuddyPress
/**
* Helper class for adding the trail items to breadcrumb trail
*
* @copyright 2018, Brajesh Singh.
*/
class BuddyDev_BP_Breadcrumb {
/**
* Add BuddyPress User/group specific trail items
@sbrajesh
sbrajesh / enable-wire-upload-with-mediapress.php
Last active December 18, 2017 10:15
Enable activity as wire upload with MediaPress
/**
* Enable activity wire upload with MediaPress.
*
* @param bool $can allow upload or not.
*
* @return bool
*/
function buddydev_enable_activity_wire_upload( $can ) {
@sbrajesh
sbrajesh / Allow Developers to Use their own custom css for background positioning etc
Created June 19, 2011 22:37
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)
//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 January 28, 2017 05:57
Add the gallery creator and media uploaders name to mediapress gallery/media.
@sbrajesh
sbrajesh / copy-png-files.php
Created August 17, 2016 10:16
Copy png files from the directory recursively to the destination directory
<?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 ) {