Skip to content

Instantly share code, notes, and snippets.

View imath's full-sized avatar
:octocat:
Moving to something new!

imath imath

:octocat:
Moving to something new!
View GitHub Profile
@imath
imath / functions-avatar.php
Created March 4, 2013 16:03
A BuddyPress trick in reply to http://buddypress.org/support/topic/display-only-members-who-have-uploaded-avatar/ : the goal is to only loop through the members who actually uploaded an avatar (instead of using gravatar). !important Make sure to backup your db before running init_evo_meta(). Once init_evo_meta() ran, make sure to delete it and l…
<?php
/************* beginning of the code to paste in the functions.php of the active theme *************/
/*
the function to to display only the users that actually uploaded an avatar
see http://buddypress.org/support/topic/display-only-members-who-have-uploaded-avatar/
*/
function evo_list_uploaded_avatars(){
@imath
imath / gist:5154740
Created March 13, 2013 18:21
Quick tip to Neutralize WordPress post revisions without modifying wp-config.php
<?php
function no_revions_for_posts() {
// see https://twitter.com/pixenjoy/status/311512790760308736
remove_post_type_support('post', 'revisions');
}
add_action( 'init', 'no_revions_for_posts', 99 );
?>
@imath
imath / bpmh-custom.php
Last active December 18, 2015 20:29
This is a skeleton to create a BP My Home (version 2.0) widget. You can use it in your plugin or in the functions.php file of your active theme.
<?php
/**
* 1- Extending WP_Widget
*
* Make sure to prefix your class with BPMH_
* and to add a classname prefixed by bpmh-
*
*/
class BPMH_Widget_Custom extends WP_Widget {
@imath
imath / user_restrict.php
Created June 22, 2013 15:15
A reply to one of my blog's comment. The goal is to restrict the content to a BuddyPress member and to run nested shortcode. Example of use : [user_restrict user_id="3"][bc_groups][/user_restrict]
<?php
/*
Restricting content to the user_id
Requires BuddyPress 1.7 & Bowe Codes 2.0.1
*/
class Restrict_Content_User_Shortcode{
function __construct() {
$this->setup_filters();
}
@imath
imath / gist:6048371
Created July 21, 2013 12:05
A reply to one of my blog comment to force alphabetical order for bc_members shortcode. See http://imathi.eu/2011/05/15/bowe-codes/comment-page-1/#comment-17190
<?php
/** begining of code to copy paste in functions.php of active theme **/
/**
* Forces the order of bc_members to be alphabetical if an alpha class has been added
*
* Using the class argument of bc_members allows to only filter the members_args
* if the class 'alpha' prepends my_members class. Keeping my_members class will maintain
* css rules.
@imath
imath / functions.php
Created September 17, 2013 14:38
Example of use of Bowe Codes to add your very own BuddyPress shortcodes. You can paste the above code in the functions.php of your active theme
<?php
/**
* Building a new BuddyPress shortcode
* using Bowe Codes built-in "API"
*
* You'll need Bowe Codes : http://wordpress.org/plugins/bowe-codes/
* And BuddyPress 1.7+
*/
@imath
imath / bpgmq.php
Created November 4, 2013 03:39
This is the complete class for the BuddyPress Codex article : Group Meta Queries: Usage Example. You can test it copying it in the functions.php of your active theme
<?php
/* you can copy & paste from here */
//it's important to check the BP_Group_Extension is available
if( class_exists( 'BP_Group_Extension' ) ) :
/**
* This is a quick and dirty class to illustrate "bpgmq"
* bpgmq stands for BuddyPress Group Meta Query...
* The goal is to store a groupmeta in order to let the community administrator
@imath
imath / events-manager-trick.php
Created November 11, 2013 16:15
Displays the list of attendees when on single event page of WordPress plugins "Events Manager". This trick requires BuddyPress to run.
<?php
/**
* Script to copy in your activated theme functions.php for instance
* Make sure BuddyPress and Events Manager are activated on your blog before using this trick
*/
// beginning of the code to copy paste
function imath_displays_confirmed_attendees( $output = '', $object = false, $target = '' ) {
@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