Skip to content

Instantly share code, notes, and snippets.

View imath's full-sized avatar
:octocat:
building the Retraceur PHP software!

imath imath

:octocat:
building the Retraceur PHP software!
View GitHub Profile
@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 / imath-pm-friends-only.php
Last active May 3, 2023 06:24
I was writing my second BuddyPress tutorial for wpformation.com when i realized it could be helpful for a community admin to restrict private messages to friends only...
<?php
/*** beginning of the code to paste in your functions.php ***/
function imath_pm_button_only_if_friends( $button ) {
if( is_super_admin() )
return $button;
if( 'is_friend' != friends_check_friendship_status( bp_displayed_user_id(), bp_loggedin_user_id() ) )
return false;
@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 / 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 / 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-customize-registration.php
Created December 16, 2012 18:11
This is a BuddyPress gist. Using it in your active theme will allow you to manage a regular WordPress user meta in the registration form. Just above the profile fields form, you'll see a new text input 'Usermeta'. You can customize the different references to a random user meta i used (bp_cr_usermeta) by your own.
<?php
// Exit if accessed directly
if ( !defined( 'ABSPATH' ) ) exit;
/****
You should paste this into a file (in the example below : bp-customize-registration.php )
in your active theme's folder, then depending if your theme is a child theme or not you should
use this code in your functions.php to include the trick
@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
**********/