Site logo

Archived topic

A better BuddyPress integration

12 replies · Started by Gabriele on April 11, 2017

Viewing posts 1–13 of 13

Hi,
I would like to ask your help in achieving a better BuddyPress integration whit GP.
In particular I'm struggling to integrate a BuddyPress user nav menu into the primary nav of GP.
I have tried with different methods (shortcodes in menu, php, mega menu plugins) but I can't succeed in finding the right way to accomplish the job as I'm not really skillful in coding.
Please could you help me with that, maybe is something useful also for other people using BuddyPress with GP.
The goal is to have an exact copy of the BuddyPress toolbar user nav in the primary nav of GP (with username, avatar and notifications counter exactly like the toolbar).
I would like also to have this exact replica in the slideout menu (it is actually set only for mobile devices) so is also available for mobile users.
For reference I was trying to use this snippet https://gist.github.com/danbp/8d10eab2895953ee6289 as base for doing the job but it didn't work very well because it applies to all menus (I have also a secondary nav below the header) and don't work correctly in the slideout menu. Also the code is old and create few errors in the error.log and I suspect looking at the code there is for sure a more cleaner way to do the same job.

Also I'm trying to find a better way to present BuddyPress content.
In GP the whole thing looks very basic, too much unrefined to actually use it on a live website. Maybe it would be possible to simply format BuddyPress profile content in a way similar when using a WordPress default theme like Twenty Sixteen.
Out of the box the GP loses the user profile navigation layout structure present in the WordPress default themes like Twenty Sixteen, which is a much cleaner way to show the user content.
I have found a useful article related to the Genesis framework to accomplish that http://wpbeaches.com/fixing-buddypress-css-genesis-theme-profile-page/
but for me is not an easy task to apply those fixes to GP.
Maybe this is something worth doing to really improve the support of BuddyPress in the GP theme.

Thanks,
Gabriele

I'm not really familiar with BuddyPress, and it's not a massively popular request among GP users so GP only has basic compatibility.

For the menu, you can try this: https://gist.github.com/generatepress/79f376ecbf53d0ba164bceda652ade55

Untested, but should only add it to the primary menu.

Not sure about the slide-out menu - might be worth using the standard BP toolbar on mobile?

In that custom content CSS, if you remove any reference to body.full-width-content, it should work in GP.

Let me know :)

Hi Tom,
thanks for your help.

For the menu I tested your modified snippet and actually it works pretty well but there is some problem in the output.
The snippets displays the avatar all way up in the menu expanding by consequence the navigation height, despite my settings in GP: https://www.dropbox.com/s/txo06y840j9ye73/issue.png?dl=0
I managed to move the avatar to the correct position with css, but but even in that lower position it forces anyway the navigation height to be higher than it was, as if the avatar is still in that higher position only hidden and moved.
Also is it possible to add the drop-down arrow to this menu element (after the username) like all the others menu links?

Regarding the slide-out menu, the standard bp toolbar is not an option, because I'm using a plugin called LifterLMS that eliminates the toolbar for all the users for managing students accounts.
Couldn't it be possible to simply apply the same snippet even to the slide-out menu?

Finally, for the custom content css, I'll try to remove the references and see if it works ;)

Thanks,
Gabriele

Finally I noticed that the buddypress menu has also a weird behavior in the mobile menu, it looses the "click to open" standard GP behavior for the mobile sub-likns and drop-down arrows, is there a way to restore the original GP behavior?

For the slide-out menu, try replacing this:

if ( $args->theme_location !== 'primary' ) {
    return $menu;
}

With this:

if ( $args->theme_location !== 'primary' && $args->theme_location !== 'slideout' ) {
    return $menu;
}

For the other issues, any chance you can link me to the site so I can take a look?

Yes thanks it works, but there are always the same two problems I was talking before:

FIRST
the snippet displays the avatar all way up in the menu expanding by consequence the navigation height, despite my settings in GP is 60px height.
I managed to move the avatar to the correct position with css, but but even in that lower position it forces anyway the navigation height to be higher than it was, as if the avatar is still in that higher position only hidden and moved.
Also is it possible to add the drop-down arrow to this menu element (after the username) like all the others menu links?

SECOND
the snippet in the slide-out has also a weird behavior, it looses the “click to open” standard GP behavior for the mobile sub-likns and drop-down arrows and in the end it blocks all the sub-links of the buddypress menu so they are simply not available. is there a way to restore the original GP behavior for this element?

You can see the website at https://dev-tenthousandbuddhas.pantheonsite.io but you will need to create an account because you must be a logged in user to see the user menu.
Please simply register to the website, I will delete the account when we don't need it anymore...

There are also some problem with the svg logo position and resize when used in the sticky main navigation and in the mobile header, please could you take a look also at that?

Thanks again for your help,
Gabriele

Yes, there were still some links pointing to the local site.
Now should work correctly, please give it a try again.

and happy Easter!

Try this:

.main-nav .avatar {
    height: 30px;
    width: auto;
    top: 8px;
    left: 5px;
}

It seems BP is prevent GP from adding our arrow, which initiates the drop down.

However, you could skip that step and just show the sub-menu items immediately:

.menu-item-900 > ul.sub-menu {
    display: block !important;
}

Thanks Tom but I suspect the problem with arrows is not related to buddypress because it happens the same with any shortcode added to the GP menu.
In the meantime I found a different way to accomplish that with Max Mega Menu plugin, after asking to them they have added the support for BuddyPress avatar and notifications counter menu items in their latest dev version, so now it's an easier way for creating the buddypress user menu.
Also if someone else is interested in tweaking the buddypress GP templates to looks like a WordPress default theme like Twenty Sixteen the css is:

#buddypress #object-nav {
	border-right:1px solid #ddd;
	float:left;
	margin-right:-1px;
	width:200px
 	}
 	#buddypress #object-nav ul {
 	background:0 0;
 	border-bottom:0;
 	padding:0
 	}
 	#buddypress #object-nav ul li {
 	float:none;
 	overflow:hidden
 	}
 	#buddypress #object-nav ul li span {
 	background:#fff;
 	border-radius:10%;
 	float:right;
 	margin-right:2px
 	}
 	#buddypress #item-body {
 	border-left:1px solid #ddd;
 	overflow:hidden;
 	padding:0 0 0 20px;
 	width:auto;
 	}
 	#buddypress #item-body #subnav {
 	margin:0 0 0 -20px
 	}
 	#buddypress #item-body #subnav ul {
 	margin-top:0
 	}

I also suggest for a better result to tweak the "#buddypress #object-nav" width percentage for mobile devices (in my case to 40% for max-width: 768px and 30% for max-width: 1024px) and disable the sidebar in buddypress pages following the instructions here https://generatepress.com/forums/topic/setting-sidebar-for-buddypressbbpresswoocommerce/

Awesome! Thanks for sharing your CSS :)

Hey Tom, I too am trying to integrate with BuddyPress, and only so my members can upload their own avatars instead of using Gravatar, and for some reason it is not recognizing the URL's etc. So when I go to any Buddypress URL, it redirects me back to the home page.

I have not switched to a different theme, to see if that does anything, but we are using a GP child theme that we created...

Oh, and LOVE this theme by the way. Been using WordPress for 10+ years, and it is hands down the best I have used!! THANKS!!

Hi David,

That might be a question more geared towards the BuddyPress support team as I'm not familiar with their avatar functionality.

Glad you like the theme!

This archived topic is closed to new replies.