Skip to content

Instantly share code, notes, and snippets.

View pbrocks's full-sized avatar

Paul Barthmaier pbrocks

View GitHub Profile
@pbrocks
pbrocks / pmpro-set-enddate-null.sql
Last active September 19, 2018 18:05 — forked from strangerstudios/set_enddate_null.sql
This SQL query will clear the expiration date for active recurring memberships in Paid Memberships Pro (PMPro).
# BACKUP FIRST
# You generally do not want to setup PMPro levels
# with both a recurring billing amount AND
# an expiration date.
# This SQL query will clear the expiration date
# for active recurring memberships.
# BACKUP FIRST
UPDATE wp_pmpro_memberships_users
SET enddate = '0000-00-00 00:00:00'
WHERE status = 'active'
@pbrocks
pbrocks / pmpro-register-helper-fields-examples.php
Last active September 6, 2018 18:48 — forked from andrewlimaza/rh_fields_example.php
Paid Memberships Pro Register Helper field type examples shows an example of every possible field in Register Helper
<?php
/**
* This example is to show you the 'niche' options each Paid Memberships Pro - Register Helper Add-on field can take and how to use it.
*
* Add this to a Customizations Plugin and customize to suit your needs
*/
function initialize_pmprorh_fields() {
// don't break if Register Helper is not loaded
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
@pbrocks
pbrocks / pmpro_isOrderRecurring.php
Created August 23, 2018 19:16 — forked from strangerstudios/pmpro_isOrderRecurring.php
Perform an action on Paid Memberships Pro (PMPro) recurring orders only.
/*
Perform an action on PMPro recurring orders only.
A recurring order here is one that
(1) Has an earlier order with the same subscription_transaction_id.
(2) Is not created at PMPro checkout.
Note that we are checking if function_exists for pmpro_isOrderRecurring incase
we add this to PMPro core. Also note that the $test_checkout param there is used
here to avoid #2 above. So this parameter will check if the currently running PHP
script is being fired at checkout, not necessarily if the order was created at checkout,
@pbrocks
pbrocks / wp-auto-installer.js
Created August 14, 2018 23:25 — forked from mohandere/wp-auto-installer.js
Wordpress auto installer script PHP
;(function($){
/*
Script Name: WP Auto Installer
Author: Mohan Dere
Version: 1.0
Description : This script install new wordpress setup, create database with tables with content & run search replace database for new urls.
Last Update: 13 Mar 15
*/
@pbrocks
pbrocks / my-pmpro-additional-categories.php
Last active August 14, 2018 15:35 — forked from strangerstudios/my_pmpro_additional_categories.php
Add "Purchase Additional Access" box to Membership Checkout for a la carte category purchase.
<?php // Do not include this line in your Customizations plugin
/**
* Require specific category user meta to view posts in designated categories.
* Custom price-adjusting fields are added via PMPro Register Helper add on (required).
* Add all of this code to your active theme's functions.php or a custom plugin.
*/
add_filter( 'pmpro_has_membership_access_filter', 'my_pmpro_additional_categories', 10, 4 );
function my_pmpro_additional_categories( $hasaccess, $thepost, $theuser, $post_membership_levels ) {
global $wpdb;
@pbrocks
pbrocks / open-new-posts-to-non-members.php
Last active August 3, 2018 03:01 — forked from strangerstudios/open_new_posts_to_non_members.php
PMPro Customizations to allow non-members to view restricted posts if they are less than 30 days old.
<?php // do not include this line
/**
* Allow non-members to view restricted posts if they are less than 30 days old.
*
* Add this code to a custom plugin.
*
* Change the '-30 Days' below if you'd like to allow access for longer or shorter.
*/
/**
* [open_new_posts_to_non_members description]
@pbrocks
pbrocks / existing code to git repo
Created July 20, 2018 19:03 — forked from zenideas/existing code to git repo
Adding existing source to remote git repo
If you've got local source code you want to add to a new remote new git repository without 'cloning' the remote first, do the following (I often do this - you create your remote empty repository in bitbucket/github, then push up your source)
1. Create the remote repository, and get the URL such as git://github.com/youruser/somename.git
2. If your local GIT repo is already set up, skips steps 2 and 3
3. Locally, at the root directory of your source, git init
4. Locally, add and commit what you want in your initial repo (for everything,
git add .
@pbrocks
pbrocks / code.js
Created July 5, 2018 22:21 — forked from MaruscaGabriel/code.js
DIVI theme JavaScript code snippets
//Open external links into new tab
<script type="text/javascript">
jQuery('a').filter(function () {
return this.hostname != window.location.hostname;
}).attr('target', '_blank');
</script>
//Adding Fly-in Animations To Any Divi Section, Row and Module
//thanks to Gino Quiroz : https://quiroz.co/adding-fly-in-animations-to-any-divi-module/
//Below are the CSS Class groups for each animation.
@pbrocks
pbrocks / customizer-links.php
Created July 5, 2018 22:19 — forked from slushman/customizer-links.php
How to link into the WordPress Customizer
<?php
//phpDoc for new PMPro function
/**
* A description of what the function does.
*
* @param {array, string, int, objext} {$variable_name} {Short description}
* @return {array, string, int, mixed, object} {$variable_name} {Short description}
*
* {@internal Any To-Dos etc.}
*