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, 2010Today, 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
So, 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.
You 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
Related posts:
- Creating a Buddypress/Wordpress Username availability checker for your site
- Blog Categories for Groups Plugin
- Stealth Mode for Buddypress Site Admin Plugin
- Remove Buddypress admin bar from all blog except the main buddypress site
- BP Redirect to profile Plugin :redirect Users to their profile on Login on buddypress sites

Nice one Brajesh, thank you.
As for what I “want something more to do with you admin panel ” – that’s a lot
Cheers
haha, I was just using these on my own box and thought to share
Brajesh,
Where to I paste these codes?
I don’t have a bp-custom.php
hi Greg, If you want, create a bp-custom.php in your plugins directory and paste the code, otherwise, just download the attached tiny plugin and install/activate. Both will do the work.
Hello Brajesh, I’m using Wordpress 2.9.2 and Buddypress 1.2.1, but the theme CosmicBuddy and BpNicey don’t work good. So, I want to Upgrade my Wordpress 2.9.2 to Wordpress MU. Have you any trick to upgrade to Wordpress MU. Please email me. . . .
Soubhik Sinhababu
CEO
Bookmania.in team
hi Soubhik
These themes should work with wordpress except for the Blogs directory part.
Still, if you want to upgrade, please follow the advises here
http://welcome.totheinter.net/2008/10/04/how-to-migrate-from-wordpress-to-wordpress-mu/
Thanks
Brajesh
hy Brajesh i have few question:
-how to add profile link(I don’t know the url profile) on the header (like home, blogs, members,forum,etc) ?
-how to edit the registration page because i want to delete blog details in the sign up pages?
thank’s
jeremy
we have already discussed here
http://buddydev.com/forums/topic/how-do-you-create-a-subpage#post-2290
When I added you code into my bp-custom.php file I got the following errors on my login page (wp-login.php)
Any idea on why this is happening and how to fix this?
Warning: Cannot modify header information – headers already sent by (output started at …/wp-login.php on line 302
Warning: Cannot modify header information – headers already sent by (output started at …/wp-login.php on line 314
Warning: Cannot modify header information – headers already sent by (output started at …/wp-login.php on line 316
Thanks,
Kalman
hi Kalman
Please make sure you have no spaces before./after php begingn and closing tags.
Brajesh,
Thanks for the help, I removed all the blank lines and everything seems to be working great.
Thanks again,
Kalman