Skip to content

Instantly share code, notes, and snippets.

@shanebp
shanebp / directory tab error
Last active May 13, 2016 14:37
Add a custom tab to Members Directory and load custom template
<?php
// add tab 'Testo' on Members Directory Page
function asdf_testo_tab() {
if ( ! bp_current_component( 'members' ) )
return;
if ( bp_is_current_action( 'testo' ) )
@shanebp
shanebp / bp-prevent-duplicate-group-names.php
Created March 29, 2016 17:22
BuddyPress prevent duplicate Group Names
function pp_check_group_name( $group_new ) {
if ( 'group-details' == bp_get_groups_current_create_step() ) {
$args = array(
'per_page' => null,
'populate_extras' => false,
'update_meta_cache' => false
);
@shanebp
shanebp / bp-email-debug.php
Last active March 7, 2016 19:59
Plugin: send debug emails to site admin re BP_Mail
<?php
/* plugin name: BP Email Debug */
add_action( 'bp_send_email_failure', 'pg_bp25_email_debug_failure', 10, 2 );
add_action( 'bp_send_email_success', 'pg_bp25_email_debug_success', 10, 2 );
function pg_bp25_email_debug_failure( $status, $email ) {
$email_admin = bp_get_option( 'admin_email' );
if ( is_wp_error( $status ) ) {
@shanebp
shanebp / single.php
Created November 24, 2015 13:41
BuddyPress single message template - reverse order and reply box at top
<div id="message-thread">
<?php
/**
* Fires before the display of a single member message thread content.
*
* @since BuddyPress (1.1.0)
*/
do_action( 'bp_before_message_thread_content' ); ?>
@shanebp
shanebp / bp-profile-tab-and-subnav.php
Last active June 28, 2023 18:11
BuddyPress add profile tab and subnav
function add_animal_tabs() {
global $bp;
bp_core_new_nav_item( array(
'name' => 'Animals',
'slug' => 'animals',
'parent_url' => $bp->displayed_user->domain,
'parent_slug' => $bp->profile->slug,
'screen_function' => 'animals_screen',
'position' => 200,
@shanebp
shanebp / gist:b0dcae45709fba43e41c
Created March 25, 2015 15:02
comments tracking test
function create_post_type_resource() {
register_post_type( 'resource',
array(
'labels' => array(
'name' => __( 'Resources' ),
'singular_name' => __( 'Resource' ),
'add_new' => __( 'Add New' ),
'add_new_item' => __( 'Add New Resource' ),
'edit' => __( 'Edit' ),
'edit_item' => __( 'Edit Resource' ),
@shanebp
shanebp / bp-add-sortby
Last active September 30, 2017 14:04
Members Loop - add Sort By option
// add a Sort By option to the members loop.
// this code assumes that the 'Extended Profile' (xprofile) component is activated
// this code assumes that a Profile Field called 'Price' and of type = 'Number' has been created
function shanebp_add_sortby_price() {
?>
<option value="price">Price</option>
<?php
}
@shanebp
shanebp / custom wp toolbar for BuddyPress
Last active August 29, 2015 14:11
In the wp-toolbar, change the Howdy and Name links so they don't go to profile/edit
// change the Howdy and Name links so they don't go to profile/edit
function wp_admin_bar_my_custom_account_menu( $wp_admin_bar ) {
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$profile_url = bp_loggedin_user_domain();
if ( 0 != $user_id ) {
$avatar = get_avatar( $user_id, 28 );
$howdy = sprintf( __('Welcome, %1$s'), $current_user->display_name );
$class = empty( $avatar ) ? '' : 'with-avatar';
@shanebp
shanebp / BP_Group_Extension-example
Last active May 26, 2021 16:26
example of using BP_Group_Extension
/* example of using BP_Group_Extension
* replace 'test' with something else - remember that it is case-sensitive
* checks for any selected Group Types in the 'Settings' step
*/
function test_add_group_extension() {
if ( bp_is_active( 'groups' ) ) :
@shanebp
shanebp / gist:dd7186f4997ee3c48785
Created September 24, 2014 17:01
buddypress - list the groupsthat someone else has created but I have joined
<?php if ( bp_has_groups( 'type=alphabetical&user_id=' . bp_loggedin_user_id() ) ) : ?>
<ul>
<?php while ( bp_groups() ) : bp_the_group(); ?>
<?php if( bp_get_group_creator_id() != bp_loggedin_user_id() ) : ?>
<li>
<div>
<a href="<?php bp_group_permalink() ?>"><?php bp_group_avatar_thumb() ?></a>
</div>