Skip to content

Instantly share code, notes, and snippets.

Brajesh Singh sbrajesh

Block or report user

Report or block sbrajesh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sbrajesh
sbrajesh / hide-subscribers.php
Last active May 29, 2020
Hide Subscriber Users from BuddyPress member Directory
View hide-subscribers.php
add_action('bp_ajax_querystring','bpdev_exclude_users',20,2);
function bpdev_exclude_users($qs=false,$object=false){
//list of users to exclude
if($object!='members')//hide for members only
return $qs;
$excluded_user=join(',',bpdev_get_subscriber_user_ids());//comma separated ids of users whom you want to exclude
@sbrajesh
sbrajesh / member-type-activity-rate-limit.php
Created May 13, 2020
Rate limiting based on member type using bp-activity-rate-limiter
View member-type-activity-rate-limit.php
/**
* 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
profile-loop.php for BuddyPress bp-legacy with edit group link
View profile-loop.php
<?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 Apr 11, 2020
Redirect User after successful profile photo upload on BuddyPress
View bp-profile-photo-successful-upload-redirection-helper.php
/**
* 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 Mar 12, 2020
White list users from BuddyPress Moderation
View buddypress-moderation-tools-white-list-users.php
/**
* 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 ) ) {
View buddypress-stop-group-join-notifications.php
//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 Jul 27, 2016
group open close example for Jaume
View jaume-group-open-close.php
//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
MediaPress media support for BP reshare plugin
View mpp-bp-reshare.php
// 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 Feb 3, 2020
Specific use case for Herve for profile completion.
View profile-completion-buddypress.php
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 Aug 20, 2018
Add last_activity time for all non active members on BuddyPress
View record-last-activity-time-for-all-users.php
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" )
You can’t perform that action at this time.