Displaying user profile
-
Hi.
I need to display the users profile photo or gravatar in the left sidebar on their blogs in a multiuser (WPMU) setup, with links below for adding as firend, send message and so on. If it is the owner of this profile I need to display links to edit profile, inbox, groups and so on.
I’m just a little new to buddypress and some direction on these things would be greatly appreciated.
-
The strategy is this: Create a bp_has_members() loop, passing the user id along in the
include
parameter (see https://codex.buddypress.org/developer-docs/custom-buddypress-loops/the-members-loop/ for more details about the members loop). Then, inside of that loop, use the member header at buddypress/bp-themes/bp-default/members/single/member-header.php as a template for creating the friend link, message buttons, etc.Very good. I’m digging into it to find how I only display the blog owners gravatar, excluding the rest of the list. Thank you.
Another thing: When I list these gravatars and action button links, I get just a gravatar, not the actual profile picture that has been uploaded. I do however get the actual profile picture when I view the profile on the main page. The blogs are on subdomains, not subdirectories.
It’s like this:
http://site.com/ shows the correct profile picture when editing the profile.
http://blog.site.com/ shows only the standard gravatar, except when editing the profile, cause that opens under the main domain.
I’d like the uploaded user picture for the blog owner to be displayed on the blogs instead of a standard gravatar. Any pointers on this one?You’re right that avatars on subdirectory blogs are acting a bit funky. It might be a BP bug, I have to look into it a little more. In the meantime, the following strategy might be a workaround for you. In your bp-custom.php, put a function like the following:
function bbg_avatar_paths( ) {
$root_url = get_blog_option( BP_ROOT_BLOG, 'home' );
define( BP_AVATAR_UPLOAD_PATH, ABSPATH . '/wp-content/uploads' );
define( BP_AVATAR_URL, $root_url . '/wp-content/uploads/' );
}
add_action( 'bp_loaded', 'bbg_avatar_paths', 7 );I hope I’m doing this right. I made the bp-custom.php file, put that code in between ?php wrappers, and placed it in the main theme folder. Didn’t see any changes. I’m no coder though, be gentle.
@xrun this should get you started https://buddypress.org/community/groups/bp-profile-widget-for-blogs/ for more customization as far as bringing in the “send message, follow, etc.” that would need a little more time and effort in getting the blog owner ID and relate it to the bp user and his profile actions you are looking to add, which it sounds like you want the member profile id card in the users blog sidebar. try the widget plugin first…it might be satisfactory enough. if you contact the plugin author he may even add some more of those features.
@xrun You got it all right, except that bp-custom.php should go into your plugins folder (probably wp-content/plugins).
@nahummadrid
Yes, that is some of what I was looking for. Thing is that it still only shows the standard gravatar, not the uploaded user profile image. That image was uploaded through the BP change avatar dialog on the main site ie. http://site.com and seems not to show up on the users own blog at http://blog.site.com. It does show up when going to the profile using the links in the menu bar though, those links point to the main site domain.
It is a subdomain multiuser setup, but it should still work shouldn’t it?@boonebgorges
Allright, I moved it to the wp-content/plugins folder. I can’t see any different in widgets or plugins, but I’m not sure where to look for it.
Just to clarify, I’ve been working with WPMU for a couple of years, it’s just buddypress that’s virgin territory for me.have you looked at this about the avatars not showing up. https://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/custom-avatars-arent-shown-on-single-blogs-in-wpmu/
@boonebgorges you opened my eyes to a easier way to doing this. i think your way is much more light than what i was doing. how would you suggest getting the blog owner id/user id and be sure that it is 1 admin?
BuddyPress avatars have been a constant thorn in everyone’s sides because there are so many possible configurations available for where uploads will go, and how they are displayed.
The more eyes we can get on this code is the better. Both Andy and myself have patched, adjusted, and repatched this code for the past few versions, fixing some issues and creating others.
I suspect these issues stem from the WP-singlesite to WP-multisite conversion. Where there is still a setting for singlesite domain.com/uploads/ when multisite is looking for domain.com/files/, but I’m unable to duplicate the bug so far.
I applied the patch and still have the avatar issue. I can’t see the avatars on my root site
@johnjamesjacoby
So what you are saying is that I’ll probably have less issues if going with a subdirectory structure for the multiblog setup, than I currently do with a multisite subdomain structure? It makes sense as long as the root domain constantly seems to be the variable, so to speak.Edit: I just backed up my database and files, and upgraded to BP 1.2.5.2. Neither uploaded avatars nor gravatars are showing on main domain pages nor subdomain blog pages.
Edit 2: I spoke too soon. Sorry. After removing the code added to bp-custom.php earlyer today the avatars and gravatars seem fine on both main- and subdomains. Just didn’t think to remove that after the upgrade. Excellent.
@xrun, so this issue is resolved for you?
Yes @johnjamesjacoby , the avatars show up fine on subdomains and the main blog, so that part is fine. I’d like to have the standard actions for logged in users and for visitors shown below the profile in the sidebar though, haven’t found out that just yet. If you have something on that I’d be very grateful.
Not talking about their entire forms now, just links/buttons to those actions.
I’m guessing I can do some if is_logged_in() or similar and hardcode that into the sidebar, that would be nice.@boonebgorges @johnjamesjacoby @nahummadrid
After working on other bits for a few days, I need to revisit an issue from the original post in this thread about 2 weeks ago.
I need to display the user actions for profiles, below the profile image and information in the sidebar, links for adding as friend, send message and so on. If it is the owner of this profile I need to display links to edit profile, inbox, groups and so on.
I’ve tried adding some code to the sidebar that I found in the profile php files, but they seem not to be able to connect to the profile, allthough the “Mention” link brings the user to the correct page to post an activity update. It does not include the username or any other name from the profile where that link was clicked though, so something is missing. I would really appreciate some assistance with this issue.
- The topic ‘Displaying user profile’ is closed to new replies.