Skip to content

Instantly share code, notes, and snippets.

Vaughan Montgomery vaughanm

Block or report user

Report or block vaughanm

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
@vaughanm
vaughanm / mp-custom-free-shipping.php
Created May 25, 2018
Mu-plugin to allow you to apply FREE shipping for specified shipping method in Marketpress, If cart total greater than set minimum,free shipping is applied.
View mp-custom-free-shipping.php
<?php
$free_ship_minimum = 100; // minimum total for free shipping to be applied
$shipping_method = 'weight_rate'; // the shipping method for this to be applied on.
/*
* Changes the Shipping cost on the Checkout Estimated costs page
*/
add_filter( 'mp_cart/cart_meta/shipping_total', 'mp_custom_shipping_price', 88, 2);
/*
View gist:7fccc055466d2cf8b217
function get_blog_creator_id($blog_id) {
global $wpdb;
$blog_id = (int) $blog_id;
if($blog_id !== 0) {
$email = $wpdb->query("SELECT email FROM {$wpdb->prefix}registration_log WHERE blog_id = {$blog_id}");
$user = get_user_by( 'email', $email );
return $user->ID;
@vaughanm
vaughanm / gist:c3c6fb288975b4708801
Created Dec 2, 2015
Add client Name & Date to Apps+ Cancellation Email
View gist:c3c6fb288975b4708801
function my_app_email_on_appointment_cancelled ($app_id) {
global $appointments;
$to = $appointments->get_admin_email();
$appt = $appointments->get_app($app_id);
$date = date_i18n( 'F j, Y', strtotime( $appt->start ) ) . ' at ' . date_i18n( 'G:i', strtotime( $appt->start ) );
$body = "{$appt->name} cancelled his appointment on {$date}\n\n
Appointment ID {$app_id}";
$worker_email = $appointments->get_worker_email($appt->worker);
@vaughanm
vaughanm / gist:e86802c785b706d121a4
Created Dec 2, 2015
adding user shortcode to display any user data
View gist:e86802c785b706d121a4
// Add Shortcode
function user_shortcode( $atts ) {
$a = shortcode_atts(
array(
'user_id' => get_current_user_id(),
'field' => '',
), $atts );
$user = get_user_by( 'id', $a['user_id'] );
@vaughanm
vaughanm / gist:f3b84072bb927eab8311
Created Dec 2, 2015
Sets comments to registered users only across entire network (multisite)
View gist:f3b84072bb927eab8311
function wpmudev_change_comment_settings() {
global $wpdb;
$blog_ids = wp_get_sites();
foreach($blog_ids as $blog) {
switch_to_blog($blog['blog_id']);
$wpdb->query("UPDATE {$wpdb->prefix}options SET option_value = 1 WHERE option_name = 'comment_registration'");
restore_current_blog();
}
@vaughanm
vaughanm / gist:dfb9f589db7afc1033e4
Created Dec 2, 2015
Make blogname on wordpress require a minimum of 2 numbers throughout the network (Multisite)
View gist:dfb9f589db7afc1033e4
// Filters blog signup validation methods
// Blogname must now contain minimum of 2 numbers
function wpmudev_blogname_numbers( $content ) {
global $wpdb, $domain;
$current_site = get_current_site();
$base = $current_site->path;
$blog_title = strip_tags( $content['blog_title'] );
$blog_title = substr( $blog_title, 0, 50 );
@vaughanm
vaughanm / gist:fcdc10800375c2e37eda
Created Dec 2, 2015
WPMUDEV Appointments+ Custom Reply-to & From address in outgoing emails
View gist:fcdc10800375c2e37eda
add_filter( 'app_message_headers', 'app_custom_header' );
function app_custom_header() {
$admin_email = 'your_email@email.com';
$blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
$content_type = 'text/plain';
if (!(defined('APP_EMAIL_DROP_LEGACY_HEADERS') && APP_EMAIL_DROP_LEGACY_HEADERS)) {
$message_headers = "MIME-Version: 1.0\n" .
"From: {$blogname}" .
" <{$admin_email}>\n" .
@vaughanm
vaughanm / gist:095b01130b6e5aa96aa5
Created Dec 2, 2015
Membership 2 Pro Add membership column to All users table
View gist:095b01130b6e5aa96aa5
add_action('manage_users_columns','wpmudev_add_user_m2p_column');
function wpmudev_add_user_m2p_column($column_headers) {
$column_headers['membership'] = 'Membership';
return $column_headers;
}
add_action('admin_head', 'wpmudev_custom_admin_css');
function wpmudev_custom_admin_css() {
echo '<style>
.column-membership {width: 15%}
You can’t perform that action at this time.