Skip to content

Instantly share code, notes, and snippets.

View sbrajesh's full-sized avatar

Brajesh Singh sbrajesh

View GitHub Profile
@sbrajesh
sbrajesh / bp-restrict-non-member-type-members.php
Created September 22, 2018 02:03
Only users who have atleast one member type assigned can access BuddyPress Section
/**
* 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;
}
@sbrajesh
sbrajesh / buddypress-exclude-users-member-type-from-list.php
Created September 10, 2018 14:21
Exclude Logged BuddyPress User's member type from the member lists
/**
* Filter members list for logged in user's member type.
*
* @param array $args member query args.
*
* @return array
*/
function buddydev_filter_members_list_exclude_logged_member_type( $args ) {
@sbrajesh
sbrajesh / bp-required-profile-field.php
Created August 27, 2018 08:35
Fore completion of BuddyPress Required Field
class BuddyDev_Profile_Field_Completion_Helper {
/**
* Show notice to user?
*
* @var bool
*/
private $show_notice = true;
@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" )
@sbrajesh
sbrajesh / buddypress-user-contact-form-extend.php
Created June 26, 2018 15:52
Extend BuddyPress User Contact Form
/**
* BuddyPress User Contact Form extension.
*/
class BPUCF_Custom_Extend {
public function __construct() {
$this->setup();
}
@sbrajesh
sbrajesh / gist:e10452da07ab0a68b1cf457b87a3ec66
Created June 17, 2018 20:05
Set User account inactive when they verify/activate their BuddyPress Account
/**
* Mark account status as inactive when they activate their BuddyPress account after signup.
*
* @param int $user_id user id.
*/
function buddydev_custom_keep_user_inactive( $user_id ) {
if ( ! function_exists( 'bp_account_deactivator' ) ) {
return;
}
@sbrajesh
sbrajesh / wordpress-latest-post-content-fetch.php
Last active May 13, 2018 18:57
Efficient WordPress Latest Post content fetch for a user
/**
* Fetch of Latest Post content of a user by post type.
*
* @param array $atts shortcode atts.
* @param string $content n/a
*
* @return mixed|string
*/
function buddydev_user_last_post_shortcode( $atts, $content = '' ) {
@sbrajesh
sbrajesh / buddydev-bp-bradcrumb.php
Created March 22, 2018 02:14
Add breadcrumb trail compatibility for BuddyPress
/**
* Helper class for adding the trail items to breadcrumb trail
*
* @copyright 2018, Brajesh Singh.
*/
class BuddyDev_BP_Breadcrumb {
/**
* Add BuddyPress User/group specific trail items
@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 / enable-wire-upload-with-mediapress.php
Last active December 18, 2017 10:15
Enable activity as wire upload with MediaPress
/**
* Enable activity wire upload with MediaPress.
*
* @param bool $can allow upload or not.
*
* @return bool
*/
function buddydev_enable_activity_wire_upload( $can ) {