Skip to content

Instantly share code, notes, and snippets.

View itsjusteileen's full-sized avatar
🎯
Focusing

Eileen Violini itsjusteileen

🎯
Focusing
View GitHub Profile
/*
If a parent account checks out and distributes the discount code to 3/10 of its child accounts,
the parent account should still have 7 remaining. This 7 remaining uses should persist after a
renewal by the parent account.
By default the discount codes have an expiration period of one year.
Even if they renew, the discount code expiration date is not updated.
We are hard coding the start and end date of the discount code itself in the function pmprosm_createSponsorCode()
/**
* BLOCK: gtm-audio-block
*
* Registering a basic block with Gutenberg.
* Simple block, renders and saves the same content without any interactivity.
*/
// Import CSS.
import './style.scss';
import './editor.scss';
@itsjusteileen
itsjusteileen / pmpro_checkout_end_date_example.php
Created April 1, 2019 16:17 — forked from strangerstudios/pmpro_checkout_end_date_example.php
Setup Level 3 to start next Monday and end the following Monday with Paid Memberships Pro.
/*
Setup Level 3 to start next Monday and end the following Monday
Requires PMPro 1.8.9 or higher.
Add this code to your active theme's functions.php or a custom plugin.
*/
//startdate
function my_pmpro_checkout_start_date($enddate, $user_id, $level) {
if($level->id == 3)
<?php
// http://stackoverflow.com/questions/7952977/php-check-if-url-and-a-file-exists
function is_200($url) {
$options['http'] = array(
'method' => "HEAD",
'ignore_errors' => 1,
'max_redirects' => 0
);
$body = file_get_contents($url, NULL, stream_context_create($options));
@itsjusteileen
itsjusteileen / pmprosm_sponsored_account_levels.php
Created February 8, 2019 19:11 — forked from ideadude/pmprosm_sponsored_account_levels.php
Example global settings for the PMPro Sponsored Members Add On
/*
Define the global array below for your main accounts and sponsored levels.
Array keys should be the main account level.
*/
global $pmprosm_sponsored_account_levels;
$pmprosm_sponsored_account_levels = array(
//set 5 seats at checkout
1 => array(
'main_level_id' => 1, //redundant but useful
'sponsored_level_id' => array(1,2), //array or single id
@itsjusteileen
itsjusteileen / pmpro-append-to-end.php
Last active February 3, 2019 00:10 — forked from eighty20results/pmpro-append-to-end.php
When user renews membership we append the duration to their current enddate
<?php
/*
Plugin Name: Paid Memberships Pro: Extend membership by new level duration
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: On change of level, modify the end date to add the new level's time
Version: 1.0
Requires: 4.5.3
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
@itsjusteileen
itsjusteileen / pmpro_days_left_example.php
Last active February 2, 2019 23:58 — forked from andrewlimaza/pmpro_days_left_example.php
Add days left to new membership level purchase for Paid Memberships Pro WooCommerce.
<?php
/**
* Calculate days remaining for current membership level and add it to new subscription.
* Only works for PMPro WooCommerce Integration
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* www.paidmembershipspro.com
*/
function pmprowoo_add_days_to_level( $level_array ) {
$level_obj = pmpro_getLevel($level_array['membership_id']);
@itsjusteileen
itsjusteileen / pmpro_level_expiring_soon_example.php
Created February 2, 2019 23:55 — forked from andrewlimaza/pmpro_level_expiring_soon_example.php
Change when user can renew their membership PMPro
<?php
/**
* Allow members to only renew if their membership expires in 45 days or less.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function custom_pmpro_is_level_expiring_soon( $r, $level ) {
$days = 45; //change number of days before someone is allowed to renew.
@itsjusteileen
itsjusteileen / pmpro-level-selection-popup.php
Created February 2, 2019 19:11 — forked from pbrocks/pmpro-level-selection-popup.php
PMPro Level selection popup shortcode
<?php // do no include in Customizaations Plugin
/**
* Plugin Name: PMPro Levels Popup
* Description: Add Level selection to a popup
*/
add_shortcode( 'pmpro-levels2-popup', 'pmpro_levels_select_shortcode2' );
function pmpro_levels_select_shortcode2() {
global $wpdb, $pmpro_msg, $pmpro_msgt, $current_user;
@itsjusteileen
itsjusteileen / pmpro-billing-fields-to-profile.php
Last active January 4, 2019 23:26 — forked from pbrocks/pmpro-billing-fields-to-profile.php
Add the billing fields created by Paid Memberships Pro to your user and BuddyPress profile and inclusion in the Members List CSV export
<?php
/**
* Plugin Name: PMPro Profile Fields
*
* Add PMPro billing fields to the WordPress and BuddyPress user profiles
*
* You must have installed both Paid Memberships Pro and the PMPro Register Helper plugins
*
* https://github.com/strangerstudios/pmpro-register-helper
*/