Skip to content

Instantly share code, notes, and snippets.

@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 / 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,
@shanebp
shanebp / docker-compose.yml
Last active April 27, 2019 13:32
docker compose WordPress linux
version: '3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
@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 / 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 / BuddyPress > Nouveau > Add Count to Group Tab
Last active May 20, 2021 08:45
Try to add a count bubble next to a custom group tab added via BP_Group_Extension
// Using the Nouveau template pack
// Add a count bubble on a custom tab on a user profile is straightforward
$count = get_the_count_profile( $group_id );
$class = ( 0 === $count ) ? 'no-count' : 'count';
$name = sprintf( __( 'Events <span class="%s">%s</span>', 'bp-simple-events' ), esc_attr( $class ), number_format_i18n( $count ) );
@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 / gist:5561044
Last active May 20, 2021 08:48
add subnav link to profile -> friends
add_action( 'bp_setup_nav', 'add_videos_subnav_tab', 100 );
function add_videos_subnav_tab() {
global $bp;
bp_core_new_subnav_item( array(
'name' => 'Videos',
'slug' => 'videos',
'parent_url' => trailingslashit( bp_loggedin_user_domain() . 'friends' ),
@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' ) ) :