Helping you Build Your Own Social Network!

Faster, better and easier!

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
We are Hiring new WordPress/buddyPress developers

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
  • BlinkList
  • DZone
  • FriendFeed
  • IndianPad
  • MySpace
  • Netvouz
  • Reddit
  • SphereIt
  • StumbleUpon
  • Technorati

Related posts:

  1. Enhancing The new User registration Message On WordPress Multisite and BuddyPress to make it more informative for Site Admins
  2. Creating a Buddypress/WordPress Username availability checker for your site
  3. Stealth Mode for Buddypress Site Admin Plugin
  4. BpDev Recently Created Blogs Widget: List the most recently created blogs on your wordpress mu/buddypress site
  5. Set default theme for the Newly Created blogs on your wordpress MU/buddypress Site

16 Responses to Playing With buddypress and WordPress, some codes for the site admins

  • Nice one Brajesh, thank you.
    As for what I “want something more to do with you admin panel ” – that’s a lot :-)
    Cheers

  • 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

  • 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

  • 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

  • Brajesh,

    Thanks for the help, I removed all the blank lines and everything seems to be working great.

    Thanks again,

    Kalman

  • Hello there!

    I am close to fall in depretion… I have done everything to stop WP taking my profile “button” but still nothing… :( ( I have upload and now it is activate, but still if you login and you press the profile button, you visiting the WP profile page… I dont know what I am doing wrong… I am a new one on buddypress and on wp.org but in general I had no problem. Please can you help me? I have there a test profile :
    username : lifeiswhathappenstoyou
    pass: 12345

    the blog : http://www.LifeIsWhatHappensToYou.com

    thank you in advance for your time!
    Dimitris

    • Hi Dimitris.
      I checked there on your site. It is redirecting, but redirecting to the wrong url.
      are you using any other plugin/code for redirecting/manipulating profile url and or buddypress root domain url ?

      • Thank you for your interesting! Yes I have just put your plugin on my WP with the BuddyPress plugin also! I just double check it! :( ( nothing more! My “them my login” plugin is working only for the login form and for the redirection only when you are login/logout on the same page that you was. but nothing more… :( ((

  • Hi. Barjesh
    i tried to use both codes, but not working.
    i put first code in profile.php and second code in my bp-custom.php but i don’t get the link to profile.
    please guide me.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Get Adobe Flash playerPlugin by wpburn.com wordpress themes