Skip to content

Instantly share code, notes, and snippets.

@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-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 / 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-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 / 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 / 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 / xprofile-pending-users.php
Last active March 15, 2021 13:18
BP - show xprofile data on Pending Users screen
<?php
// add the custom column header
function philopress_modify_user_columns($column_headers) {
$column_headers['extended'] = 'Meta Fields';
return $column_headers;
}
add_action('manage_users_page_bp-signups_columns','philopress_modify_user_columns');
@shanebp
shanebp / list_groups_on_members_loop.php
Created July 22, 2016 15:49
List a member's groups on the Members Directory
function shanebp_user_groups(){
$group_ids = groups_get_user_groups( bp_get_member_user_id() );
foreach( $group_ids["groups"] as $id ) {
$group = groups_get_group( array( 'group_id' => $id ) );
echo '<a href=' . trailingslashit( bp_get_groups_directory_permalink() . $group->slug . '/' ) . '>' . $group->name . '<a/><br>';
@shanebp
shanebp / tidy
Last active December 16, 2017 19:31
be specific re php version: sudo apt-get install php7.0-tidy
vagrant@vvv:~$ sudo apt-get install php-tidy
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libtidy5 php7.1-common php7.1-tidy
The following NEW packages will be installed:
libtidy5 php-tidy php7.1-common php7.1-tidy
@shanebp
shanebp / gist:0e6a1a5ca91ddf256b70fc77799a018b
Created May 20, 2018 15:10
BuddyPress - Nouveau template pack - add nav item
function add_members_directory_tab_nouveau( $nav_items ) {
$nav_items['custom'] = array(
'component' => 'members',
'slug' => 'custom',
'li_class' => array('custom no-ajax'),
'link' => trailingslashit( bp_get_members_directory_permalink() . 'custom' ),
'text' => __( 'Custom', 'buddypress' ),
'count' => false,
'position' => 15.8,