Playing With buddypress and Wordpress, some codes for the site admins

Jotted by Brajesh Singh in Buddypress, Buddypress Free Plugins, Buddypress Tricks, Plugins on February 22, 2010

Today, I am going to share 2 quick tips with you for enhancing your wordpress/Buddypress Site.

As a site admin, when I have Buddypress active, I don’t want my users to visit their wordpress profile , .e. wp-admin/profile.php, so the first tip will allow you to redirect users to their buddypress profile when they will try to open their wordpress profile.

Second, from Wordpress back end, when I am viewing the list of Users, I do want to see their buddypress profile sometime, but there are no ways other than copying the username and pasting it in the siteurl with member slug to access their profile. So, The second tip will enable you to quickly view the users buddypress profile. Lets go ahead now.
Redirecting User to Their Buddypress Profile when They access their wordpress profile(wp-admin/profile.php)
It is simple, we will hook, our code to “admin_init” action as below


//redirect user to their buddypress profile if they are trying to view their wp profile

add_action("admin_init","bpdev_redirect_user_to_bp_profile");

function bpdev_redirect_user_to_bp_profile(){
if ( !defined('IS_PROFILE_PAGE') )
return false;//if this is not the profile page, do not do anything

$current_user = wp_get_current_user();
$bp_profile_link=bp_core_get_user_domain( $current_user->ID);
bp_core_redirect($bp_profile_link);
}

Well, this code does its work. try to access your profile by clicking your name in wp dashboard and you will be redirected to your buddypress Profile.

Quick Link User profile from Wp-admin users list

This is useful for site admins. When you try to view the registerd users from Dashboard->Users->Authors And Users, what you get is a list of Users with their username, email, name and some more info.

Now, when you hover over the user name, you see the links to Edit/delete as shown below

user-infoSo, What do you do, if you want to see the Users Buddypress profile.  Perhaps copying and forming the user profile url manually or searching through the members directory. Nope! both are time killing for me!. So What I do, see here your self.

profile-linkedYou see, when I over over the User name, I get the quick link to profile.

well, that’s easy.Here is the code to accomplish it.


add_filter("user_row_actions","link_to_bp_profile",10,2);//hook our link to row actions
function link_to_bp_profile($actions,$user){
$bp_profile_link=bp_core_get_user_domain($user->ID);
$actions["profile"]="<a href='".$bp_profile_link."'>Profile</a>";//hook our link
return $actions;
}

Well, put these codes in bp-custom.php and try for your self. hope it helps.

for those who don’t feel comfortable working with code, here is a small plugin for you :)

http://buddydev.com/http//buddydev.com/public-download/wp-admin-tuning-for-bp.zip

Download it, Install it, activate and check , It should be working for you.

Let me know your thoughts, or if you know some better way/want something more to do with you admin panel :)

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Add to favorites
  • BlinkList
  • DZone
  • FriendFeed
  • IndianPad
  • MySpace
  • Netvouz
  • Reddit
  • SphereIt
  • StumbleUpon
  • Technorati

Related posts:

  1. Creating a Buddypress/Wordpress Username availability checker for your site
  2. Blog Categories for Groups Plugin
  3. Stealth Mode for Buddypress Site Admin Plugin
  4. Remove Buddypress admin bar from all blog except the main buddypress site
  5. BP Redirect to profile Plugin :redirect Users to their profile on Login on buddypress sites

12 Comments Already!

Leave a Reply

Name [*]

Email [*]

Website Optional

Comment [*]

Please Note,The fields marked as * are required fields*


Get Adobe Flash playerPlugin by wpburn.com wordpress themes