Skip to content

Instantly share code, notes, and snippets.

@danbp
danbp / gist:9cde6164796768259e741942c2d889b6
Created October 15, 2016 08:05
BuddyPress - building a member directory by member-type
function using_mt_register_member_types() {
bp_register_member_type( 'ville', array(
'labels' => array(
'name' => __( 'Par Villes', 'textdomain' ),
'singular_name' => __( 'Ville', 'textdomain' ),
),
) );
bp_register_member_type( 'pays', array(
@danbp
danbp / gist:ea92923b1109ee1fcebd0741d861cda6
Created August 23, 2016 17:29
BuddyPress Move Profile Edit edit tab to Profile Settings tab
/* This goes to child-theme style.css and will hide the Profile Edit button. */
#edit-personal-li {
display:none!important;
}
*/ And this is to put into bp-custom.php to get the Edit button on the Profile Settings subnav.
Note that there is an array field containing a new css rule for the item. */
function bpex_move_profile_edit_tab() {
@danbp
danbp / gist:342c08eb8be9432ae97f
Created September 29, 2015 09:21
BuddyPress - Add posts and comments on separate profile tabs
/**
* this goes into bp-custom.php or can be changed to a plugin
* tested with 2012 , BP 2.3.3 and WP 4.3.3
*/
// building navigation tabs
function bpfr_post_profile_setup_nav() {
global $bp;
$parent_slug = 'contributions';
$child_slug = 'posts';
/*
* Tested on BP 2.3.2.1 / Twenty Twelve
* A similar BP profile menu as under Howdy, to add to main menu.
* Code goes into bp-custom.php
*/
function bpfr_nav_menu_profile_link( $menu ) {
global $bp;
// determine user to use
@danbp
danbp / bp-custom.php
Created July 2, 2015 06:38
Usage example of BuddyPress 2.2 member_type
<?php
/**
/* BuddyPress custom functions
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
//////////////////////////////// - stuff goes here - /////////////////////////////////
/****************************************** MEMBER TYPES ********************************************/
@danbp
danbp / gist:f9c13d0b42c6e42b5545
Created April 9, 2015 01:30
BuddyPress - My Groups Widget
<?php
/*
Plugin Name: My Groups Widget
Description: This BuddyPress widget lists the groups of which the logged in user is a member.
Version: 1.0
Revision Date: March 10, 2015
Requires at least: WP 4.0, BuddyPress 2.0
Tested up to: WP 4.1.1, BuddyPress 2.2.1
License: Example: GNU General Public License 2.0 (GPL) http://www.gnu.org/licenses/gpl.html
Author: Dan
@danbp
danbp / gist:d474da401c462e30c93e
Last active August 29, 2015 14:17
BuddyPress - add a sub_nav item to profile tab
function bpfr_custom_profile_sub_nav() {
global $bp;
$parent_slug = 'profile';
//Add subnav item
bp_core_new_subnav_item( array(
'name' => __( 'Create a Group', 'buddypress' ),
'slug' => $parent_slug,
'parent_url' => $bp->loggedin_user->domain . $parent_slug.'/',
'parent_slug' => $parent_slug,
@danbp
danbp / gist:5657144
Created May 27, 2013 13:46
BuddyPress 1.7.X Add some social icons on a profile header, at the right of the avatar below the activity meta Pictures are send by CSS with the <i> tag Goes into theme's functions.php file. Tested on BP 1.7.2 and bp-default theme.
// add some social icons on a profile header
function bpfr_socialize_profile () {
echo '<br>';
//check if the field contain a value. If it has one show it.
if ( $data = bp_get_profile_field_data( 'field=Twitter ' ) ) :
?>
<a href="http://twitter.com/<?php echo xprofile_get_field_data( 'Twitter', bp_displayed_user_id() );?>/" target="_blank" title="Twitter"><i class="icon-twitter"></i></a>&nbsp;