Skip to content

Instantly share code, notes, and snippets.

View sbrajesh's full-sized avatar

Brajesh Singh sbrajesh

View GitHub Profile
@sbrajesh
sbrajesh / buddypress-filter-multi-select-profile-field-value.php
Last active June 8, 2020 20:30
Filter BuddyPress Multi select value to add extra markup
/**
* Filter BuddyPress multi select value and add spans around for custom styling.
*
* @see https://buddydev.com/support/forums/topic/add-extra-css-on-a-profile-field/
*/
add_filter( 'bp_get_the_profile_field_value', function ( $value ) {
global $field;
if ( empty( $field ) || 'multiselectbox' !== $field->type ) {
return $value;
}
@sbrajesh
sbrajesh / member-type-activity-rate-limit.php
Created May 13, 2020 09:28
Rate limiting based on member type using bp-activity-rate-limiter
/**
* Get time/count for the user
*
* @param int $user_id user id.
*
* @return array
*/
function buddydev_get_activity_mtype_based_rates( $user_id ) {
@sbrajesh
sbrajesh / profile-loop.php
Created May 9, 2020 00:23
profile-loop.php for BuddyPress bp-legacy with edit group link
<?php
/**
* BuddyPress - Members Profile Loop
*
* @package BuddyPress
* @subpackage bp-legacy
* @version 3.0.0
*/
/** This action is documented in bp-templates/bp-legacy/buddypress/members/single/profile/profile-wp.php */
@sbrajesh
sbrajesh / bp-profile-photo-successful-upload-redirection-helper.php
Created April 11, 2020 01:37
Redirect User after successful profile photo upload on BuddyPress
/**
* Redirect after successful upload of profile photo on BuddyPress.
*/
class BP_Profile_Photo_Successful_Upload_Redirection_Helper {
/**
* Singleton instance.
*
* @var BP_Profile_Photo_Successful_Upload_Redirection_Helper
@sbrajesh
sbrajesh / buddypress-moderation-tools-white-list-users.php
Created March 12, 2020 06:35
White list users from BuddyPress Moderation
/**
* BuddyPress Moderation Tools:- White List users
*
* All contents from whitelisted users are disabled from reporting.
*/
add_filter( 'bpmts_is_user_whitelisted', function ( $is, $user_id ) {
$white_listed_user_ids = [ 1, 2, 3 ];// add your own ids.
if ( in_array( $user_id, $white_listed_user_ids ) ) {
//Do not notify for join group activity in BP Local group Activity notifier
function buddydev_do_not_notify_join_group_activity( $stop_notification, $activity ) {
if ( $activity->type == 'joined_group' ) {
$stop_notification = true;
}
return $stop_notification;
}
add_filter( 'bp_local_group_notifier_skip_notification', 'buddydev_do_not_notify_join_group_activity', 10, 2 );
@sbrajesh
sbrajesh / jaume-group-open-close.php
Created July 27, 2016 19:37
group open close example for Jaume
//do not let the activity be posted by any means(do not allow from directory etc)
function bd_check_post_update() {
$item_id = 0;
$object = '';
@sbrajesh
sbrajesh / mpp-bp-reshare.php
Created May 30, 2017 13:16
MediaPress media support for BP reshare plugin
// For reshare, add mpp_media_upload type.
add_filter( 'buddyreshare_activity_types', function( $types ) {
$types[] = 'mpp_media_upload';
return $types;
});
// Filter the action string for the shared media activity
add_filter( 'buddyreshare_prepare_reshare_activity', function( $action_string, $activity ) {
if ( 'mpp_media_upload' !== $activity->type ) {
@sbrajesh
sbrajesh / profile-completion-buddypress.php
Last active February 3, 2020 11:59
Specific use case for Herve for profile completion.
class BuddyDev_Profile_Field_Completion_Helper {
/**
* Which member type should be set? PLease change it.
*
* @var string
*/
private $member_type = 'YOUR_MEMBER_TYPE'; // Please Change it.
/**
@sbrajesh
sbrajesh / record-last-activity-time-for-all-users.php
Created August 20, 2018 14:39
Add last_activity time for all non active members on BuddyPress
INSERT INTO wp_bp_activity(user_id, component, type, action, content, primary_link, item_id, date_recorded ) select ID, 'members', 'last_activity', '', '', '', 0, NOW() FROM wp_users WHERE ID NOT IN (SELECT user_id FROM `wp_bp_activity` WHERE type="last_activity" )