Skip to content

Instantly share code, notes, and snippets.

Tanner Moushey tannerm

View GitHub Profile
View autosubscribe_forum.php
add_action( 'wpmu_new_user', function( $user_id ) {
add_user_to_blog( 19, $user_id, 'participant' ); // add user to forum site as participant
// subscribe user to forum
$forum_id = 0; // update the forum id
switch_to_blog( 19 ); // switch to the correct site
bbp_add_user_forum_subscription( $user_id, $forum_id ); // add user to the forum
restore_current_blog(); // switch back to the original site
} );
View rcp_filters.php
<?php
/**
* Filter the subscriptions that can be used in the upgrade path
* original filter: https://docs.google.com/document/d/19-H7iF-6M_xuKQIF_V6VdeuwXyXaGgWAU9zrJnxavOw/edit
*/
function trm_filter_subscriptions( $subscriptions, $user_id ) {
// make sure the user is active and get the subscription ID
$user_subscription = ( rcp_is_recurring( $user_id ) && rcp_is_active( $user_id ) && 'cancelled' !== rcp_get_status() ) ? rcp_get_subscription_id( $user_id ) : '';
$subscriptions = rcp_get_subscription_levels( 'active' );
View spotx.html
<div id="spotxchange"></div>
<script type="text/javascript">
window.isMobile = function () {
var check = false;
(function (a) {
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(2
@tannerm
tannerm / remove_prev_role_meta.php
Created Aug 12, 2015
Companion function for Conditional Profile Field Groups plugin to remove invalid group meta when a user's role changes.
View remove_prev_role_meta.php
function remove_prev_role_meta( $user_id = null) {
// Define the user we are working on
if ( ! $user_id ) {
$user_id = get_current_user_id();
}
// Set valid groups
$valid_groups = bp_xprofile_get_groups( array( 'user_id' => $user_id ) );
$valid_group_ids = wp_list_pluck( $valid_groups, 'id' );
View wpmandrill-ms.php
<?php
/*
* Plugin Name: wpMandrill MS
* Plugin URI: https://gist.github.com/tannerm/b6d06e3d784f7c12bdd5
* Description: Network-wide settings for wpMandrill.
* Version: 2015.07.07
* Author: Kailey Lampert, Tanner Moushey
* Author URI: kaileylampert.com
* License: GPLv2 or later
* TextDomain: wpmandrill-ms
@tannerm
tannerm / take_this_coupons.js
Last active Aug 29, 2015
Call GravityForms custom price function before coupons while maintaining coupon functionality.
View take_this_coupons.js
/**
* Custom price the Registration form and support other custom price functions
* Yes this is kind of a hack, but we need out function to fire first
*/
var registrationTotal = function() {
var SELF = this;
SELF.init = function() {
// This would be the right way to make this happen if the coupons extension didn't mess it up
// gform.addFilter('gform_product_total', SELF.swapVars);
@tannerm
tannerm / login.js
Last active Nov 9, 2015
WordPress Ajax Login
View login.js
jQuery(document).ready(function($){
'use strict';
var ajaxLogin = function() {
var SELF = this;
SELF.data = {'security': tm.security};
SELF.init = function(id) {
SELF.$loginContainer = $(id);
View singleton.php
<?php
Singleton::get_instance();
class Singleton {
/**
* @var
*/
protected static $_instance;
@tannerm
tannerm / oo.js
Last active Aug 29, 2015
JavaScript Object Oriented
View oo.js
(function($) {
'use strict';
var myTestClass = function() {
var SELF = this;
SELF.init = function() {};
}
@tannerm
tannerm / protected.php
Created Apr 7, 2014
Protected content template
View protected.php
<?php
/** template for protected content when password is not found */
get_header(); ?>
<div class="main-content" id="content" role="main">
<h1 class="top-heading"></h1>
<div class="intro"></div>
<?php the_content(); ?>
</div>
You can’t perform that action at this time.