Skip to content

Instantly share code, notes, and snippets.

View codelion7's full-sized avatar

Christian Freeman codelion7

  • Team Extreme
  • United States
View GitHub Profile
@codelion7
codelion7 / sync_member_type_roles.php
Created August 15, 2017 04:52
Sync the roles associated with each of the user's member types on each subsite of a multisite network
/**
* Retrieves an array of all network sites
*
* @since 1.0
* @return array
*/
function get_network_sites() {
global $wpdb;
$blogs = $wpdb->get_results("
@codelion7
codelion7 / bp-global-member-types.php
Last active February 3, 2020 12:45
Enable Global Member Types in BuddyPress
<?php
/**
* Sets a user's buddypress member type(s) globally across all sites
*
* @since 1.0
*/
function bp_set_global_member_type( $user_id = 0, $member_type = '', $append = false ) {
// Append new member type to global member type array
if ( $append == true ) {
@codelion7
codelion7 / sync_member_type.php
Created August 10, 2017 05:48
Sync BuddyPress Member Type to Another Blog on a Multisite Network
<?php
function sync_member_type( $user_id = 0 ) {
if ( empty( $user_id ) )
$user_id = get_current_user_id();
$memb_types = bp_get_member_type( $user_id, false );
switch_to_blog( 3 );
@codelion7
codelion7 / dashboard-tab-referrals.php
Last active March 9, 2024 05:38
AffiliateWP Template File to Filter Out Indirect Referrals from the Direct Referrals list
<?php
$affiliate_id = affwp_get_affiliate_id();
?>
<div id="affwp-affiliate-dashboard-referrals" class="affwp-tab-content">
<h4><?php _e( 'Referrals', 'affiliate-wp' ); ?></h4>
<?php
$per_page = 30;
@codelion7
codelion7 / filters.php
Created May 8, 2017 23:56
Add Custom Driver Status Column to Affiliates Export CSV
<?php
/**
* Add Driver Status column to the exported affiliates CSV file
*
* @since 1.0
*/
function affwp_mobbyd_export_affiliates_csv_cols( $cols ) {
$cols['driver_status'] = 'Driver Status';
@codelion7
codelion7 / affwp-remove-url-field.php
Created January 18, 2017 21:40
Removes the Website URL field from the list of required affiliate registration form fields
// Run if AffiliateWP is active
if ( class_exists( 'Affiliate_WP' ) ) {
/**
* Removes the Website URL field from the list of required affiliate registration form fields
*
* @return array
*/
function affwp_remove_url_field( $required_fields = array() ) {
@codelion7
codelion7 / mlm-remove-upline-data.php
Last active January 18, 2017 20:44
Removes Specific MLM Affiliate Data from the Sub Affiliates Tooltip (Upline Only)
// Run if AffiliateWP MLM is Active
if ( class_exists( 'AffiliateWP_Multi_Level_Marketing' ) ) {
/**
* Removes Specific MLM Affiliate Data from the Sub Affiliates Tooltip (Upline Only)
*
* @since 1.1.1
* @return array
*/
function affwp_mlm_remove_upline_aff_data( $aff_data = array(), $affiliate_id = 0 ) {
@codelion7
codelion7 / course_list_template
Created January 7, 2016 23:46
LearnDash Course Grid Update
<?php
/**
* @package nmbs
*/
$col = empty($shortcode_atts["col"])? 3:intval($shortcode_atts["col"]);
$smcol = $col/1.5;
$col = empty($col)? 1:($col >= 12)? 12:$col;
$smcol = empty($smcol)? 1:($smcol >= 12)? 12:$smcol;
$col = intVal(12/$col);
$smcol = intVal(12/$smcol);
@codelion7
codelion7 / lifetime-affiliate-check.php
Last active December 6, 2022 04:33
Allow or Deny Lifetime Affiliate Overrides - Filterable
<?php
// Prevent overwriting existing lifetime affiliate
if ( get_user_meta( $user_id, 'affwp_lc_affiliate_id', true ) ) {
if( ! (bool) apply_filters( 'affwp_lc_update_affiliate', false, $affiliate_id, $user_id, $referral, $this->context ) ) {
return true; // Allow extensions to update lifetime affiliates
}
}
@codelion7
codelion7 / mycred-users-rank-progress-shortcode
Last active September 19, 2016 11:52
myCRED Custom Shortcode: Rank Progress
<?php
// Get user's rank progress
function get_mycred_users_rank_progress( $user_id, $show_rank ) {
global $wpdb;
if ( ! function_exists( 'mycred' ) ) return '';
// Change rank data to displayed user when on a user's profile
if ( function_exists( 'bp_is_user' ) && bp_is_user() && empty( $user_id ) ) {