Skip to content

Instantly share code, notes, and snippets.

Avatar

Brajesh Singh sbrajesh

View GitHub Profile
@sbrajesh
sbrajesh / buddypress-filter-multi-select-profile-field-value.php
Last active Jun 8, 2020
Filter BuddyPress Multi select value to add extra markup
View buddypress-filter-multi-select-profile-field-value.php
/**
* 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
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 Recount all members to account excluded member types
add_filter( 'bp_core_get_active_member_count', function ( $count ) {
// protect from errro if plugin is disabled.
if ( ! class_exists( 'BPMTP_Member_Types_Pro' ) ) {
return $count;
}
// optimize.
$current_count = get_transient( 'bpmtp_all_active_members' );
if ( false !== $current_count ) {
View show media with MediaPress activity comments
/**
* Attach media with comments on a mediapress activity.
*
* @param int $comment_id comment id.
* @param array $r args.
* @param BP_Activity_Activity $activity activity object.
*/
function mpp_custom_comment_posted( $comment_id, $r, $activity ) {
@sbrajesh
sbrajesh / bp-user-redirect.php
Created Aug 11, 2019
Redirect BuddyPress User to their activity instead of home page
View bp-user-redirect.php
/**
* Redirect users to login if not not logged, otherwise, redirect to user activity.
*/
function buddydev_custom_user_home_page() {
if ( ! is_user_logged_in() ) {
bp_core_redirect( wp_login_url( site_url( '/' ) ) );
}
@sbrajesh
sbrajesh / custom-redirect-bp-autoactivate.php
Created May 15, 2019
Custom redirect after auto activation/auto login
View custom-redirect-bp-autoactivate.php
/**
* Redirect user to some page on site when automatically activated and logged in.
*
* @param string $url url to redirect to.
* @param int $user_id user id.
*
* @return string
*/
function buddydev_custom_activation_redirect( $url, $user_id ) {
@sbrajesh
sbrajesh / bp-custom.php
Created Feb 27, 2019
Empty bp-custom.php for your own usage
View bp-custom.php
<?php
// your php custom code goes below this line.
You can’t perform that action at this time.