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 / 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.
@sbrajesh
sbrajesh / hide-subscribers.php
Last active Feb 26, 2019
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 / user-report-message-thread.php
Created Feb 19, 2019
Add user report button in message thread.
View user-report-message-thread.php
/**
* Add block/unblock button on single message thread.
*/
function buddydev_show_user_report_button_on_message_thread() {
// only message involving single user can be blocked.
if ( ! function_exists( 'bpmts_report_button' ) || ! bp_is_my_profile() ) {
return;
}
@sbrajesh
sbrajesh / gist:cc37e8794527f86046e1d880490d974b
Created Jan 9, 2019
BuddyPress Private Message Rate Limiter, Role based customization
View gist:cc37e8794527f86046e1d880490d974b
/**
* Get the applicable limit for the given role.
*
* @param string $role role name.
*
* @return array
*/
function buddydev_custom_get_role_based_message_limit( $role ) {
@sbrajesh
sbrajesh / gist:42843929a5b89c3065ee2ae6b1e6a904
Created Dec 11, 2018
Use a text field as a way to link to other users profile on BuddyPress
View gist:42843929a5b89c3065ee2ae6b1e6a904
class BP_Other_User_As_Profile_Field {
/**
* Field id, replace with actual field id.
*
* @var string
*/
private $field_id = 25; // Chang it with actual field id.
@sbrajesh
sbrajesh / hv2.php
Created Nov 5, 2018
Featured Member Expiration based on role
View hv2.php
/**
* Class BP_Featured_Member_Expirable_Membership
*
* @author Ravi Sharma
*/
class BP_Featured_Member_Expirable_Membership{
/**
* Singleton Instance
@sbrajesh
sbrajesh / current-group-autojoin-for-bp-ajax-registration.php
Created Oct 4, 2018
Auto join user to current group when using BuddyPress Ajax Registration plugin.
View current-group-autojoin-for-bp-ajax-registration.php
/**
* Auto join user to current group when using BuddyPress Ajax Registration plugin.
*
* @param int $user_id user id.
*/
function buddydev_auto_join_current_group_on_activation( $user_id ) {
if ( bp_is_group() ) {
groups_join_group( groups_get_current_group()->id, $user_id );
@sbrajesh
sbrajesh / bp-restrict-non-member-type-members.php
Created Sep 22, 2018
Only users who have atleast one member type assigned can access BuddyPress Section
View bp-restrict-non-member-type-members.php
/**
* Restrict access to BuddyPress to members having assigned member type.
*/
function buddydev_protect_bp_from_non_members() {
// Do not restrict if
// Not BuddyPress, or Registration/Activation page or is site admin.
if ( ! is_buddypress() || bp_is_register_page() || bp_is_activation_page() || is_super_admin() ) {
return;
}
You can’t perform that action at this time.