Skip to content

Instantly share code, notes, and snippets.

View pbrocks's full-sized avatar

Paul Barthmaier pbrocks

View GitHub Profile
@pbrocks
pbrocks / hide-toolbar-non-manager.php
Created August 30, 2017 23:18
Hide the WordPress Toolbar for non-admins and non-Membership Managers
<?php
/**
* Plugin Name: PMPro Customizations
*/
add_action( 'init', 'disable_toolbar_on_frontend', 9 );
function disable_toolbar_on_frontend() {
if ( ! current_user_can( 'pmpro_membership_manager' )
&& ! current_user_can( 'administrator' ) ) {
add_action( 'admin_enqueue_scripts', 'hide_toolbar_in_edit_user_settings' );
@pbrocks
pbrocks / pmpro-add-manager-capabilities.php
Created September 13, 2017 20:41
Gist adds or removes capabilities to the PMPro Membership Manager role.
add_action( 'admin_init', 'add_roles_to_membership_manager', 22 );
function add_roles_to_membership_manager() {
$manager = get_role( 'pmpro_membership_manager' );
if ( $manager ) {
$manager->add_cap( 'edit_plugins' );
$manager->add_cap( 'activate_plugins' );
$manager->add_cap( 'promote_users' );
$manager->remove_cap( 'pmpro_addons' );
$manager->remove_cap( 'pmpro_memberslist' );
$manager->remove_cap( 'remove_users' );
@pbrocks
pbrocks / pmpro-reg-helper-custom.php
Created October 2, 2017 01:26
Adding two custom fields for PMPro Register Helper Add On
/**
* Adding additional PMPro Register Helper Fields
*/
function pmpro_additional_wp_user_checkout_fields() {
if ( class_exists( 'PMProRH_Field' ) ) {
pmprorh_add_checkout_box( 'additional', 'Additional Information' );
$fields = array();
/**
* Team Name field
@pbrocks
pbrocks / pmpro-add-columns-csv-export.php
Created October 11, 2017 00:01
Illustration of how to add columns to the PMPro Members Export CSV
<?php
/*
* Add Previous Level, Start Date, Date Level Changed, and End Date columns to Members List CSV.
* To achieve this, we are using a PMPro filter which then calls a function for its value,
* one function for each of the columns added.
*/
function refitrev_column_changes( $columns ) {
$columns = array(
'previous level' => 'refitrev_changes_previous_level',
'start date' => 'refitrev_changes_start_date',
# .htaccess main domain to subfolder redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line.
RewriteEngine on
# Change yourdomain.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.com$
@pbrocks
pbrocks / html-tooltips.html
Created October 23, 2017 18:36 — forked from tomhodgins/html-tooltips.html
HTML inside Bootstrap tooltips
<!DOCTYPE html>
<html>
<head>
<title>Tooltip HTML Styles</title>
<!-- Bootstrap: with responsive, no icons -->
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/css/bootstrap-combined.no-icons.min.css" rel="stylesheet">
<!-- FontAwesome -->
<link href="http://netdna.bootstrapcdn.com/font-awesome/3.0.2/css/font-awesome.css" rel="stylesheet">
@pbrocks
pbrocks / get-customer-number.js
Created November 2, 2017 15:32
JS as part of AJAX call
jQuery(document).ready(function($) {
$('#location_select_submit').click(function() {
$.ajax({
type: "POST",
url: location_select_script.location_select_ajaxurl,
data: {
// Variables defined from form
action : 'location_select_action',
serialize : $('#location-select-form').serialize(),
custjson : $('#custjson').val(),
@pbrocks
pbrocks / index.html
Created November 11, 2017 22:31
SVG Scrolling Animation Drawing
<!-- SVG image credit to http://www.flaticon.com/authors/freepik -->
<h1>SVG animation</h1>
<h2>Scroll down and let the magic happen!</h2>
<svg id="glasses" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 1068 610" enable-background="new 0 0 1068 610" xml:space="preserve">
<path fill="none" d="M469,253c0-65-102-90-182-90c-119,0-171,12-171,133c0,68,23,163,146,163c55,0,120-8,170-82C451,346,469,294,469,253z M785,165c-99,0-179,23-179,88c0,24,9,74,28,112c35,66,90,94,171,94c125,0,150-64,150-190C955,190,912,165,785,165z M287,145 c104,0,190,37,249,37c65,0,137-36,268-36c49,0,158,16,206,22c7,1,9,2,9,10c1,16,1,32,1,49c0,6-3,8-6,8c-15,0-23,17-26,33 c-5,30-11,60-18,89c-22,88-75,118-169,118c-123,0-170-50-213-165c-12-30-13-62-52-62c-29,0-41,30-52,62c-33,85-75,164-217,164 c-52,0-127-21-153-83c-12-31-27-107-30-130c-3-15-10-24-24-29c-6-1-7-6-7-11c0-14,0-36,1-45c1-10,3-13,14-14C88,162,210,145,287,145 z"/>
</svg>
@pbrocks
pbrocks / functions.php
Created November 28, 2017 22:41
Files needed for a child theme of Memberlite WordPress theme.
<?php
/**
* Child theme functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package WordPress
* @subpackage parent-strap
* @since 1.0
*/
/**
* Replacment for lines https://github.com/strangerstudios/pmpro-vat-tax/blob/master/pmpro-vat-tax.php#L530-L570
*/
function pmprovat_pmpro_payment_option_fields( $payment_option_values, $gateway ) {
global $pmpro_european_union, $pmpro_vat_by_country;
if ( isset( $_REQUEST['pmprovt_seller_country'] ) ) {
$seller_country = sanitize_text_field( $_REQUEST['pmprovt_seller_country'] );
update_option( 'pmprovt_seller_country', 'ES' );
} else {