5 Great BuddyPress Quick Tips from our Community
BP-Tricks has only launched a week ago, but we’ve already receive quite a few great tricks to spice up your BuddyPress site. Here are some of this weeks submitted quick tips:
Tip 1: Using a custom excerpt for new blog posts entries
R-A-Y from BuddyPress.org has created a simple snippet which gives you back control over how the excerpt will be displayed in new Blog Post entries. Here’s the code:
function my_bp_post_excerpt($activity_content, $post, $permalink) { if($post->post_excerpt) return $post->post_excerpt; else return $activity_content; } add_filter( 'bp_blogs_activity_new_post_content', 'my_bp_post_excerpt', 1, 3 );
Done!
Tip 2: Zebra Styling of Activity Stream items
If you want to make your activity streams a bit easier to read, you might want to add Zebra styling to the entries. Marco72 tell us how on BuddyPress.org
/*> Activity Stream Listing --------------------------------------------------------------*/ UL.activity-list LI { padding: 20px 0 0; overflow: hidden; } UL.activity-list>LI:first-child { padding-top: 5px; }
right after that add:
UL.activity-list>li:nth-child(even) { background-color: #EFEFEF; border-bottom: 1px solid #D5D5D5; border-top: 1px solid #f4f4f4; }
Tip 3:Remove Profile Auto-Links
Place:
remove_filter( ‘bp_get_the_profile_field_value’, ‘xprofile_filter_link_profile_data’, 50 );
in your theme’s bp-custom.php file. If your theme doesn’t have one yet, then create it.
Tip 4:Show a Geo-widget like on BP.org
Place the following code anywhere you like. This can be in your (child theme’s) Sidebar.php file or in the Member-Header.php file (found in Members/Single/ in the theme directory)
Location · Edit
You now have the same widget as on the profile pages on BP.org!
Tip 5: Close down your site for logged-in members only
This code snippet will make most Buddypress pages viewable to members only. The exceptions being the registration and activation pages. And also blog pages are viewable to unregistered users. Unregistered users trying to access members only pages will be redirected to the front page.
Place the function below into functions.php in your theme folder:
function sh_walled_garden() { global $bp; if ( bp_is_register_page() || bp_is_activation_page() ) return; if( ! bp_is_blog_page() && ! is_user_logged_in() ) bp_core_redirect( $bp->root_domain .\'/\'. BP_REGISTER_SLUG ); } add_action( \'walled_garden\', \'sh_walled_garden\' );and this right on top of header.php (before the
Script courtesy of Traveljunkie
Add your Quick Tips!
Adding your own quick tips is really easy. Why don’t you sent in one now?. It can be any code snippet you like, as long as you tell us your source and a short description of what it does .
Nice, THanks!
Awesome tricks!