Skip to content

Instantly share code, notes, and snippets.

View imath's full-sized avatar
🔌
Contributing to #BuddyPress

imath imath

🔌
Contributing to #BuddyPress
View GitHub Profile
@imath
imath / bp-custom.php
Last active August 29, 2015 13:57
Faire en sorte que les pages BuddyPress ne soient accessibles qu'aux membres connectés.
<?php
/**
Seulement visible pour les utilisateurs connectés
Portion de code à mettre dans bp-custom.php
Voir le codex: http://codex.buddypress.org/plugindev/bp-custom-php/
**/
function check_is_user_logged_in() {
if ( ! is_buddypress() )
return;
@imath
imath / bp-custom.php
Created July 23, 2014 00:49
Happy Birthday !
<?php
/**
* Il y a effectivement un problème avec l'utilisation de bp_member_profile_data()
* dans le Members loop @see https://buddypress.trac.wordpress.org/ticket/4891
*
* J'avais indiqué un moyen de contournement sur le forum de BuddyPress.org
* @see http://buddypress.org/support/topic/possible-bug-with-bp_member_profile_data-and-date-selector/
*
* Dans le cas présent, je pense qu'il est de toute façon plus judicieux d'utiliser xprofile_get_field_data
* tout en désactivant réactivant le filtre xprofile_filter_format_field_value_by_field_id pour disposer de la
@imath
imath / functions.php
Created July 30, 2014 09:26
MesoColumn Theme & BuddyDrive : fixing user nav css issue
<?php
/**
* Override BuddyDrive default css by filtering buddydrive_global_css
*
* The array to return needs to be like :
*
* array(
* 'stylesheet_uri' => url to the new css file
* 'deps' => array of registered css dependencies
* )
@imath
imath / bp-custom.php
Created August 31, 2014 10:28
Restrict the use of BuddyDrive to a minimum capability
<?php
function restrict_to_a_role() {
if ( ! bp_is_user() || buddydrive_get_slug() != bp_current_component() ) {
return;
}
// Change 'bp_moderate' with the capability of your choice
if ( ! bp_current_user_can( 'bp_moderate' ) ) {
// Remove actions
@imath
imath / wp-idea-stream-custom.php
Created September 30, 2014 11:52
Example of actions and filters to use to customize the behavior of WP Idea Stream
<?php
/**
* WP Idea Stream Custom.
*
* Place here the function to customize Version 2.0+ of WP Idea Stream
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
@imath
imath / wp-idea-stream-custom.php
Created October 3, 2014 12:34
Neutralize hashbuddy filter.
<?php
/**
* Name me as wp-idea-stream-custom.php
* and put me in /wp-content/plugins/
*/
function qobalt_remove_hashbuddy_filter() {
if ( ! wp_idea_stream_is_single_idea() ) {
return;
}
@imath
imath / bp-custom.php
Created February 5, 2015 17:36
Temporarly fix to BuddyPress Links when used with BuddyPress 2.2.
<?php
/**
* This is temparary, please advise the plugin author to use the BP_Component Class
* @see https://github.com/boonebgorges/buddypress-skeleton-component/blob/1.7/includes/bp-example-loader.php
*/
function buddypress_links_temporary_fix( $retval, $component = '' ) {
if ( 'links' != $component ) {
@imath
imath / bp-custom.php
Created February 6, 2015 14:27
BuddyPress member types : display the type near each user in the members loop (requires BuddyPress 2.2)
<?php
/**
* Using BuddyPress Member types API
*
* see codex: https://codex.buddypress.org/developer/member-types/
*
* Required config:
* - WordPress 4.1
* - BuddyPress 2.2
*
@imath
imath / wp-idea-stream-custom.php
Created February 8, 2015 18:37
WP Idea Stream Custom : Replace the author avatar by the first image found in the idea content
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Replace the author avatar by the first image found in the idea content
* if no image was found keep the avatar.
*/
function first_idea_image_as_avatar( $avatar_link, $author, $avatar, $idea ) {
if ( empty( $idea->post_content ) ) {
<?php
// Exit if accessed directly
defined( 'ABSPATH' ) || exit;
/**
* This will only get the displayed group's menu items
* 1/ if a group is displayed
* 2/ if the theme is containing the template 'buddypress/groups/single/home.php'
* 3/ if the theme's template replaced <ul><?php bp_get_options_nav();?></ul> by <?php bp_nav_menu();?>
*/