Skip to content

Instantly share code, notes, and snippets.

@shanebp
shanebp / gist:3353337
Created August 14, 2012 21:48
BuddyPress - Group Extension API - delete button
//within the plugin and within the Extension class
function edit_screen() {
...
<?php if ( is_user_logged_in() && function_exists( 'bp_delete_test_page_link' ) ) : ?>
<a class="button confirm" href="<?php bp_delete_test_page_link(); ?>">Delete Test Page</a>
<?php endif; ?>
...
}
@shanebp
shanebp / gist:5391229
Created April 15, 2013 20:56
BuddyPress - add message button in members loop
function filter_message_button_link( $link ) {
$link = wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r=' . bp_core_get_username( bp_get_member_user_id() ) );
return $link;
}
function display_private_message_button() {
if( bp_get_member_user_id() != bp_loggedin_user_id() ) {
bp_send_message_button();
add_filter('bp_get_send_private_message_link', 'filter_message_button_link', 1, 1 );
@shanebp
shanebp / buddypress PST time correction
Created May 1, 2013 19:34
Filter time if off by 7 hours
// add 7 hours in the filters below
function shane_local_time( $timestamp ) {
$unixTimestamp = strtotime( $timestamp );
$unixTimestamp = $unixTimestamp + (7 * 3600);
$filtered_time = date("Y-m-d H:i:s", $unixTimestamp);
return $filtered_time;
@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' ),
re: http://buddypress.org/support/topic/show-only-members-with-avatars-on-member-loop/
untested, but cleaned up...
/********* SEARCH MEMBERS BASED ON PROFILE FIELDS *********/
function gd_custom_ids( $field_name, $field_value = '' ) {
if ( empty( $field_name ) )
return '';
/*
If you are using BP 2.1+, this will insert a Country selectbox.
Add the function to bp-custom.php and then visit .../wp-admin/users.php?page=bp-profile-setup
Remove this function after the field is created.
*/
function bp_add_custom_country_list() {
if ( !xprofile_get_field_id_from_name('Country') && 'bp-profile-setup' == $_GET['page'] ) {
@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>
@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 / 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-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
}