Skip to content

Instantly share code, notes, and snippets.

View toluaddy's full-sized avatar
💭
I may be slow to respond.

toluaddy

💭
I may be slow to respond.
View GitHub Profile
@toluaddy
toluaddy / buddypress-exclude-users-member-type-from-list.php
Created February 3, 2020 10:59 — forked from sbrajesh/buddypress-exclude-users-member-type-from-list.php
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 ) {
@toluaddy
toluaddy / gist:77ca4c23ff1c60d0f2e6f31ed4beb1c2
Created February 3, 2020 11:53 — forked from rolandinsh/gist:5941257
update BuddyPress xprofile programmatically
<?php
function smc_update_xprofile($userid,$field,$value) {
// alternative to get user ID
// global $current_user;
// get_currentuserinfo();
// $field = 'Foo'; // xProfile field name
// $value = 'bar'; // desired value
// xprofile_set_field_data($field, $current_user->id, $value);
@toluaddy
toluaddy / add-to-buddypress-groups-based-on-xprofile-selection-upon-activation.php Add to BuddyPress groups and bbPress forum subscription based on xProfile checkbox selection
/*
Add to BuddyPress groups and forums (including sub-forums) based on xProfile checkbox selection
*/
function my_bp_core_signup_user($user_id)
{
$groups = array(1 => "HIKING",
2 => "PADDLING",
3 => "CYCLING",
4=> "SKIING",);
@toluaddy
toluaddy / yz-register-sabai-post-actions.php
Created February 3, 2020 12:00 — forked from KaineLabs/yz-register-sabai-post-actions.php
Register Subai Questions & Answers
/**
* Register Subai Actions.
*/
function yz_register_subai_post_actions() {
// Init Vars
$bp = buddypress();
bp_activity_set_action(
$bp->activity->id,
@toluaddy
toluaddy / bp_redirect.php
Created February 3, 2020 12:04 — forked from remkus/bp_redirect.php
BuddyPress Privacy
<?php
add_filter( 'get_header', 'bp_guest_redirect', 1 );
/**
* Redirect BuddyPress guests to register page
* @return [type] [description]
*/
function bp_guest_redirect() {
global $bp;
if ( bp_is_activity_component() || bp_is_user_profile() || bp_is_groups_component() || bp_is_blogs_component() || bp_is_page( BP_MEMBERS_SLUG ) ) {
@toluaddy
toluaddy / hide_add_friend_button_pmpro.php
Created February 3, 2020 12:06 — forked from andrewlimaza/hide_add_friend_button_pmpro.php
hide 'Add Friend' in BuddyPress when a user does not have an active membership with Paid Memberships Pro.
<?php
/**
* Hide 'Add Friend' button in BuddyPress if a user does not have an active membership level.
* Add this code to your PMPro Customizations plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Visit www.paidmembershipspro.com
*/
function pmpro_hide_add_friend_if_non_member( $button ) {
if ( pmpro_hasMembershipLevel() ) { //if the user has a membership level, show the 'add friend button'.
@toluaddy
toluaddy / add-roles-to-avatar-classes.php
Created February 3, 2020 12:10 — forked from dcavins/add-roles-to-avatar-classes.php
Add the user's roles to the classes applied to a BuddyPress avatar.
<?php
add_filter( 'bp_get_member_avatar', 'my_add_user_level_to_avatars', 10, 2 );
/**
* @param string $value Formatted HTML <img> element, or raw avatar URL based on $html arg.
* @param array $r Array of parsed arguments. See {@link bp_get_member_avatar()}.
*/
function my_add_user_level_to_avatars( $value, $r ) {
global $members_template;
// The args have already been parsed in bp_get_member_avatar. We'll use them except for the css class.
@toluaddy
toluaddy / filter-author-link-to-bp-profile.php
Created February 3, 2020 12:11 — forked from dcavins/filter-author-link-to-bp-profile.php
Filter the WordPress author link to point to the author's BP profile rather than the WP-standard author post archive.
@toluaddy
toluaddy / yz-force-bp-covers-activation.php
Created February 3, 2020 12:11 — forked from KaineLabs/yz-force-bp-covers-activation.php
Force Buddypress Covers Activation.
/**
* Force Buddypress Covers Activation.
*/
function youzer_activate_buddypress_covers() {
return true;
}
add_filter( 'bp_is_profile_cover_image_active', 'youzer_activate_buddypress_covers', 999 );
add_filter( 'bp_is_groups_cover_image_active', 'youzer_activate_buddypress_covers', 999 );