BuddyDev

Search

by bphelp

Permalink: #576

Remove groups tab from user profile

// Remove groups tab from profile
// adjust accordingly to remove other items! Simple huh?
// Enjoy!
function bphelp_remove_groups_from_profile(){
bp_core_remove_nav_item('groups');
}
add_action('bp_groups_setup_nav','bphelp_remove_groups_from_profile');

#remove-groups-tab-from-profile

by bphelp

Permalink: #530

Redirect logged out visitors to home, and logged in users to profile

// I was contacted by a BuddyDev user on how to accomplish this based on another
// code snippet I posted here so here is my solution. Add this code to bp-custom.php
// to redirect logged out visitors to the home page and redirect logged in users to
// their profile. Keep in mind that if you attempt to go to the home page while
// logged in then it will redirect you to your profile. Not tested with multisite!
// Enjoy!

function bp_help_redirect_to_profile(){
if( is_user_logged_in() && is_home() ) {
bp_core_redirect( get_option( 'home' ) . '/members/' . bp_core_get_username( bp_loggedin_user_id() ) . '/profile/' );
}else {
if ( !is_user_logged_in() && !bp_is_register_page() && !bp_is_activation_page() && !is_home() )
bp_core_redirect( get_option( 'home' ) );
}
}
add_action( 'template_redirect', 'bp_help_redirect_to_profile',1 );

#redirect-logged-out-vistors-home-and-logged-in-users-to-profile

by bphelp

Permalink: #485

Remove activity tab from user profile

// I was asked how to remove the activity tab for everyone on
// the BP user profiles so here is my quick solution. Add the
// code below to bp-custom.php and it will remove that tab
// and if the user even tries to get to it by manually typing
// the URL in their browser they get "Page Not Found."
// Hope others find this useful.
function bphelp_remove_activity_from_profile(){
    bp_core_remove_nav_item('activity');
}
add_action('bp_activity_setup_nav','bphelp_remove_activity_from_profile');

#remove-profile-activity-tab

by bphelp

Permalink: #451

Redirect Logged Out Visitors To Register, And Logged In Users To Profile Using A Dummy Page


// PLEASE NOTE FOR THIS TO WORK: // Before adding this code to bp-custom.php // http://codex.buddypress.org/developer/customizing/bp-custom-php/ // you will need to create a new page in the dashboard and name it // something like “Dummy Page” for example or any name you choose. // Do not add this page to your menu because it is just a dummy page // for the redirect. Then go to Dashboard/Settings/Reading. // Under “Front page displays” select “A static page.” Then use the // “Front page” drop-down menu to select the page you created. In my // example for instance I selected “Dummy Page” for my front page. // Done! Now logged out visitors get redirected to the register page, // and logged in users get redirected to their profile. /* Redirects to profile upon login, and logged out users are redirected to register page */ function bp_help_redirect_to_profile(){ if( is_user_logged_in() && bp_is_front_page() ) { bp_core_redirect( get_option('home') . '/members/' . bp_core_get_username( bp_loggedin_user_id() ) . '/profile/' ); }else { if ( !is_user_logged_in() && !bp_is_register_page() && !bp_is_activation_page() ) bp_core_redirect( get_option('home') . '/register/'); } } add_action( 'get_header', 'bp_help_redirect_to_profile',1);

#redirect

by Brajesh Singh

Permalink: #438

Do not allow Private Galleries using Bp Gallery

add_filter( 'gallery_get_valid_status', 'bpcustom_filter_gallery_status', 100 );
function bpcustom_filter_gallery_status( $stati ){
    //do not allow private
    unset($stati['private']);//you can do the same for public, friendsonly too

    return $stati;

}

#bp-gallery

by Brajesh Singh

Permalink: #428

Extending Breadcrumb Trail plugin for BuddyPress breadcrumb navigation

//filter and append our items to breadcrumb trails
add_filter('breadcrumb_trail_items', 'hibuddy_include_bp_items',10,2);

function hibuddy_include_bp_items($trail, $args){


     global $bp;

     //current action
     $action = isset( $bp->canonical_stack['action'] ) ? $bp->canonical_stack['action'] : '' ;
     $component = isset( $bp->canonical_stack['component'] ) ? $bp->canonical_stack['component'] : '';
     $action_variables = isset( $bp->canonical_stack['action_variables'] ) ?  $bp->canonical_stack['action_variables'] : array();

     $trail_end = '';

     //is user component
     if( bp_is_user() ){
         //remove trail_end
        unset($trail['trail_end']);
        //add Members Page as Link
        $trail[] = "<a href='".get_permalink($bp->pages->members->id)."'>".get_the_title($bp->pages->members->id)."</a>"; 


        //if component is empty, it will just list the user display name as end point
        //we may improve it to show the default component title instead in future

        if( empty( $component ) ){
            $trail['trail_end'] = bp_get_displayed_user_fullname ();
        }else{
            //if we are here, we are most probably on a component screen of user
            $trail[] = bp_core_get_userlink(bp_displayed_user_id());
            //find the details about current nav item
            $nav_details = hibuddy_find_nav_details($bp->bp_nav, $component);
            //let us keep the name of current nav menu as end point
            $trail_end = $nav_details['name'];

            //are we doing some action for the component
            if( !empty( $action ) ) {
                //yes, then let us link to the parent component on user
                $trail[] = "<a href='". $nav_details['link']."'>".$nav_details['name']."</a>";

                $subnav_details = hibuddy_find_subnav_details( $component, $action );

                //let us keep that sub nav action name as the end point
                $trail_end = $subnav_details['name'];

            }

            if( !empty( $action_variables ) ){

                //is some action_variable set
                //if yes, let us append the parent action link to the breadcrumb
                $trail[] = "<a href='". $subnav_details['link']."'>".$subnav_details['name']."</a>";

                $trail_end = array_pop( $action_variables );

                foreach( $action_variables as $action_name )
                    $trail[] = ucwords(str_replace('-', ' ', $action_name));

               $trail_end = ucwords( str_replace('-', ' ', $trail_end ) );
            }

        }



    }elseif( bp_is_active('groups') && bp_is_group() ){

         unset($trail['trail_end']);
         //let us append the group parent page as link       
         $trail[] = "<a href='".get_permalink($bp->pages->groups->id)."'>".get_the_title($bp->pages->groups->id)."</a>"; 


        //get the current group details
         $current_group = groups_get_current_group();

         //if no action is set, we are on group home page
         if( empty( $action ) ){
            $trail['trail_end'] = bp_get_group_name( $current_group );
         }else{
            //we are on any of group internal page

            $trail[]= "<a href='".  bp_get_group_permalink( $current_group )."'>".  bp_get_group_name( $current_group )."</a>";

            $subnav_details = hibuddy_find_subnav_details( $current_group->slug, $action );


            $trail_end = $subnav_details['name'];

            if( !empty( $action_variables ) ){
                $trail[] = "<a href='". $subnav_details['link']."'>".$subnav_details['name']."</a>";



                $trail_end = array_pop( $action_variables );
                foreach( $action_variables as $action_name )
                    $trail[] = ucwords( str_replace('-', ' ', $action_name ) );

               $trail_end = ucwords(str_replace('-', ' ',$trail_end ));


            }


        }



    }

//that's all folks for the User/group
//what other components do you use,
//I was planning to write the 3rd section to handle the non core components having their own single pages(e.g. events etc)
// but I need some suggestion about one of the plugins to see if I can have a generic way of doing it
    //append trail end
     if( !empty( $trail_end ) )
            $trail['trail_end'] = $trail_end;

     return $trail;

}
/**
 * 
 * Iterates over a multi dimensional array and finds the array item that has a slug name which matches item name
 * @global type $bp
 * @param mixed $collection array of nav items
 * @param type $item_name slug name to match against
 * @return mixed|boolean
 */
function hibuddy_find_nav_details($collection, $item_name){



    foreach( $collection as $nav_item){

        if($nav_item['slug']== $item_name){

            //let us manipulate the link
            if ( bp_loggedin_user_domain() ) 
            $nav_item['link'] = str_replace( bp_loggedin_user_domain(), bp_displayed_user_domain(), $nav_item['link'] );

            return $nav_item;

        }
    }

    return false;
}
/**
 * Find the subnav array 
 * @global type $bp
 * @param type $component : component name groups etc
 * @param type $action which action eg. admin/forums etc
 * @return mixed array of sub nav item details 
 */
function hibuddy_find_subnav_details( $component, $action ){
    global $bp;

    $main_nav = $bp->bp_options_nav[$component];


    return hibuddy_find_nav_details( $main_nav, $action );

}

#buddypress #breadcrumb #bp-hacks

by naijaping

Permalink: #412

change email from wordpress at domain dot com

add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');

function new_mail_from($old) {
 return 'noreply@yourdomain.com';
}
function new_mail_from_name($old) {
 return 'Put Whatever Name you want';
}

by naijaping

Permalink: #370

Auto send message to email of user which account is being Deleted(You can change the message as suit you)

function myb_delete_user($user_id) {
global $wpdb;
    $email = $wpdb->get_var("SELECT user_email FROM $wpdb->users WHERE ID = '" . $user_id . "' LIMIT 1");

     $headers = 'From: ' . get_bloginfo("name") . ' <' . get_bloginfo("admin_email") . '>' . "\r\n";
     wp_mail($email, 'You are being deleted, Mate', 'Your account at ' . get_bloginfo("name") . ' is being deleted right now.', $headers);
}
add_action( 'delete_user', 'myb_delete_user');