Playing With BuddyPress and WordPress, some codes for the site admins
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
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | /** * Redirect user to profile. */ function bpdev_redirect_user_to_bp_profile() { // if this is not the profile page, do not do anything. if ( ! defined( 'IS_PROFILE_PAGE' ) ) { return; } $bp_profile_link = bp_core_get_user_domain( get_current_user_id() ); bp_core_redirect( $bp_profile_link ); } add_action( 'admin_init', 'bpdev_redirect_user_to_bp_profile' ); |
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 registered 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 hover over the user name, I get the quick link to profile.
well, that's easy. Here is the code to accomplish it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | /** * Add profile link in user row actions. * * @param array $actions actions. * @param WP_User $user user. * * @return array */ function link_to_bp_profile( $actions, $user ) { $bp_profile_link = esc_url( bp_core_get_user_domain( $user->ID ) ); $actions['profile'] = "<a href='{$bp_profile_link}'>Profile</a>"; return $actions; } // hook our link to row actions. add_filter( 'user_row_actions', 'link_to_bp_profile', 10, 2 ); |
Put these codes in bp-custom.php and try for yourself. Hope it helps.
Let me know your thoughts, or if you know some better way/want something more to do with you admin panel 🙂
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
https://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
🙂
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.
Hi Brajesh! Thanks a whole bunch for this, really usefull enhancement with the direct link to the profile page!
Thank you Magnus.
Appreciate the comment 🙂
Hello, I have noticed with this plugin that I can no longer edit my own profile without it redirecting to my buddypress profile. I wanted to be able to still access the personal options dashboard by clicking edit. /wp-admin/profile.php
It has options for the toolbar and such that aren't accessible through going straight to the buddypress profile, any help with this?
Hi Nicole,
That is the purpose of this plugin. I don't think you need this plugin if you don't want to redirect the users.
I do want to redirect users. But in the wordpress panel > users. When clicking on edit on other users it's fine. But clicking edit on my own profile redirects me. I wanted to still be able to access that dashboard as admin.
the plugin link is not working , it gives 404 🙁 🙁
the plugin link is not working , it gives 404 🙁 🙁 , please advise how can i find the plugin?
Sorry for the inconvenience. I have just updated the link to the correct upload file. It got changed when we updated our site last and was causing the trouble.
Hope that helps.
Thanks
Brajesh
Brajesh,
Is there any difference between the plugin and adding the code into bp-custom.php? Will one have better/faster performance?
Hi Johnathan,
No, there is no actual difference.