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
Created September 3, 2015 06:26
Add BuddyDrive editor to the BuddyPress compose private message screen, the button will appear over the submit one
<?php
function test_bp_message_compose() {
// Always check the editor is available to prevent fatals!
if ( bp_is_my_profile() && function_exists( 'buddydrive_editor' ) ) {
// 'message_content' is the id attribute of the textarea to send private messages
buddydrive_editor( 'message_content' );
}
}
add_action( 'bp_after_messages_compose_content', 'test_bp_message_compose' );
@imath
imath / bp-custom.php
Created February 20, 2015 19:47
Filtering bp_ajax_querystring
<?php
/**
* Filter the querystring when on the activity directory
*
* @param string/array $query_string component loop arguments
* @param sting $object component name
* @return string the edited query string
*/
function bphelp_ajax_querystring( $query_string, $object ) {
@imath
imath / bp_loggedin_user_shortcode.php
Created November 26, 2012 08:58
displaying BuddyPress user's home page link if he's connected into a WordPress post, page or text widget
<?php
/*** displaying BuddyPress user's home page link if he's connected into a WordPress post, page or text widget ***/
/*********
Beginning of the code to paste in the functions.php of your active theme
**********/
@imath
imath / bp-search-post-cats.php
Last active December 11, 2015 09:48
adds some categories to BP Default header search (dropdown options) in order to search within this categories...
<?php
/*** based on http://buddydev.com/buddypress/making-buddypress-activity-searchable/ ***/
/* simply paste what follows in your functions.php file */
add_filter( 'bp_search_form_type_select_options', 'kendyman_seventeen_options', 10, 1);
function kendyman_seventeen_options( $options ) {
$args = array(
@imath
imath / bp-tag-nav-item.php
Created February 2, 2013 18:09
In reply to this topic : http://bp-fr.net/groupes/utilisation-configuration-optimisation-de-buddypress/forum/topic/comment-ajouter-un-nouveau-critere-de-tri-aux-topic/ . Adding a new nav item to BuddyPress Forum dir (in case of bbPress 1.2 powered forums..) for a given topic tag.
<?php
/*** Beginning of the code to paste into the functions.php of your BuddyPress theme / child theme ***/
/**
* Hooks bp_forums_directory_group_types and adds a forum directory nav item
*
* @global $wp_taxonomy_object
* @uses $wp_taxonomy_object->get_term_by() to fetch tag datas by name
* @uses bb_get_tag_link() to get permalink for the given tag id.
* @author imath
@imath
imath / mathieu-hides-member.php
Created February 3, 2013 14:25
this is a little BuddyPress trick to hide friends nav and activity friends subnav to members visiting other member profiles. It's a reply to this topic : http://bp-fr.net/groupes/utilisation-configuration-optimisation-de-buddypress/forum/topic/supprimer-longlet-amis-de-la-fiche-dun-membre/
<?php
/**** beginning of the code to copy in the functions.php file of active theme ****/
function mathieu_hides_friends_nav( $nav_items, $nav_items_args ) {
if( is_super_admin() )
return $nav_items;
if( bp_is_user() && !bp_is_my_profile() )
return false;
@imath
imath / bastien-delete-own-topic.php
Created February 5, 2013 13:48
Allows members to delete their own topic in BuddyPress group forums. I advise you to be very careful with this script as BuddyPress normaly only allows group admin or super admin to delete topics.
<?php
/** Beginning of the code to copy in the functions.php of your active theme **/
function bastien_own_topic_delete() {
if( bp_get_the_topic_is_mine() && ( !bp_is_item_admin() || !bp_is_item_mod() || !bp_current_user_can( 'bp_moderate' ) ) ) {
?>
<div class="admin-links" style="margin-right:50px!important">
@imath
imath / bp-function-restrict-group-activity-comments.php
Last active December 13, 2015 19:59
BuddyPress trick to disallow group activity comments or comment replies to non members of the group
<?php
/*** beginning of the code to paste in the functions.php of your theme ***/
function imath_wants_you_to_be_in_group_to_comment_group_activities( $can_comment ) {
global $activities_template;
if( !is_super_admin() && $activities_template->activity->component == 'groups' && !groups_is_user_member( bp_loggedin_user_id(), $activities_template->activity->item_id ) )
$can_comment = false;
@imath
imath / gist:5049922
Created February 27, 2013 17:48
A simple BuddyPress trick to avoid saving activities when members are becoming friends or when a member joins a group.
<?php
/* beginning of the code to paste in the functions.php of your active theme */
function imath_activivity_dont_save( $activity_object ) {
// friendship_created is fired when a member accepts a friend request
// joined_group is fired when a member joins a group.
$exclude = array( 'friendship_created', 'joined_group');
// if the activity type is empty, it stops BuddyPress BP_Activity_Activity::save() function
@imath
imath / tmp-functions.php
Last active December 14, 2015 10:59
This is a quick and dirty attempt in order to use the custom page template (an Admin can define in the WP Editor template select box) with BuddyPress 1.7 Theme Compat. I think the main challenge is not in loading the custom template, but it's too understand how the theme is rendering the layout. For instance : twentyeleven and twentytwelve are u…
<?php
/*
beginning of the code to paste in the functions.php of the active theme (twentyten, twentyeleven or twentytwelve)
If you want to adapt it to your theme, you'll need to check if it uses some body_class to render its layout and eventually
adapt lines 70 to 101.
*/
class Imath_WP_Editor_Template
{