Skip to content

Instantly share code, notes, and snippets.

View LMNTL's full-sized avatar

Jessica Thomas LMNTL

  • Chicago, IL
View GitHub Profile
@LMNTL
LMNTL / pmpro_after_change_membership_level_default_level.php
Last active April 23, 2019 21:02 — forked from strangerstudios/pmpro_after_change_membership_level_default_level.php
Place a PMPro member in another level with a 30 day expiration date when they cancel/expire unless they are cancelling from that level.
function my_pmpro_after_change_membership_level_default_level($level_id, $user_id)
{
//set this to the id of the level you want to give members when they cancel
$cancel_level_id = 1;
//if we see this global set, then another gist is planning to give the user their level back
global $pmpro_next_payment_timestamp;
if(!empty($pmpro_next_payment_timestamp))
return;
@LMNTL
LMNTL / pmpro-file-upload-avatar-register-helper.php
Last active October 11, 2019 13:10 — forked from greathmaster/pmpro-file-upload-avatar-register-helper.php
Upload avatar image from the checkout using the PMPro Register Helper Add On. No other plugins required.
/*
* Add WP User Avatar from Register Helper field during checkout.
*/
function my_updated_user_meta($meta_id, $user_id, $meta_key, $meta_value) {
// Change user_avatar to your Register Helper file upload name.
if( 'user_avatar' == $meta_key) {
$filename = $meta_value['fullpath'];
$filetype = wp_check_filetype( basename( $filename ), null );
$wp_upload_dir = wp_upload_dir();
$attachment = array(
@LMNTL
LMNTL / pmprorh-validate-on-profile-edit.php
Last active April 26, 2019 20:26
Add custom validation for Register Helper fields when editing from profile page
/*
Add custom validation for Register Helper fields when editing from profile page.
Requires Paid Memberships Pro and Register Helper Add On.
*/
function my_pmprorh_user_profile_validate_rhfields($errors, $update, $user) {
if( isset( $_POST['my_errors'] ) ){
$my_errors = $_POST['my_errors'];
foreach( $my_errors as $single_error){
$errors->add('my_pmprorh_error',__($single_error));
@LMNTL
LMNTL / pmprozapier_email_after_change_level.php
Last active August 27, 2019 07:41
Send WP new user email and PMPro admin change email after registering a member through a PMPro Zapier zap
// send WP new user email and PMPro admin change email after registering a member through a PMPro Zapier zap
// requires Paid Memberships Pro and PMPro Zapier add on
function my_pmpro_zapier_email_after_change_level( $level_id, $user_id ){
if( isset( $_SERVER["REQUEST_URI"] ) && ( strpos( $_SERVER["REQUEST_URI"], "pmpro_zapier_webhook" ) !== false ) ){
$user = get_userdata( $user_id );
$pmpro_email = new PMProEmail();
$pmpro_email->sendAdminChangeEmail( $user );
wp_new_user_notification( $user_id, null, 'both' );
}
@LMNTL
LMNTL / pmprosd_prorate_delay.php
Created May 6, 2019 22:45
Custom proration for a level with a subscription delay until a specified date (like "Y1-08-01"). Requires Paid Memberships Pro and Subscription Delays Add On.
// Custom proration for levels with a subcription delay until a specified date (like "Y1-08-01").
// Prorates initial payment based on days until end of subscription delay for level 1
function my_pmprosd_prorate_delay( $level )
{
// change this to the ID of the membership level to prorate
if( $level->id == 1 ){
// change this to the day of year the subscription delay ends, in MM-DD format
$subscription_day = "08-01";
@LMNTL
LMNTL / pmpro_always_show_discount_code.php
Created May 9, 2019 17:12
Always show the top discount code field on the checkout page for Paid Memberships Pro
// Always show the top discount code field on the checkout page for Paid Memberships Pro
function my_pmpro_always_show_discount_code()
{
?>
<script>
jQuery(document).ready(function() {
jQuery('#other_discount_code_tr').show();
jQuery('#other_discount_code_p').hide();
jQuery('#other_discount_code').focus();
});
@LMNTL
LMNTL / pmpro-add-role-custom-roles.php
Last active May 20, 2019 18:44 — forked from strangerstudios/pmpro-change-role-custom-roles.php
Add a custom role for new PMPro members at checkout. Add this code to your active theme's functions.php or a custom plugin. - based on https://gist.github.com/strangerstudios/7280471
<?php
/*
This code assumes you already have a 'myrole' custom role created.
Members signing up get the 'myrole' role in addition to any other roles they already have.
Members cancelling are given the subscriber role.
Admin users are ignored.
Usable with or without the PMPro Roles Add On.
*/
function my_pmpro_after_change_membership_level($level_id, $user_id)
{
function my_custom_memberslist_order($sqlQuery)
{
echo "<a href=".admin_url('admin.php?page=pmpro-memberslist&enddate_sort=asc').">Sort by Enddate ASC</a><br>".
"<a href=".admin_url('admin.php?page=pmpro-memberslist&enddate_sort=desc').">Sort by Enddate DESC</a>";
if(isset($_REQUEST['enddate_sort']) && ($_REQUEST['enddate_sort'] == 'asc' || $_REQUEST['enddate_sort'] == 'desc'))
{
$sort_order = $_REQUEST['enddate_sort'];
global $wpdb;
@LMNTL
LMNTL / 2checkout_short_signup.php
Created May 16, 2019 20:01
Use the short version of the 2Checkout signup form when checking out with PMPro.
/*
Use the short version of the 2Checkout signup form when checking out.
After installing and activating this, you'll also need to enable "SHORT_FORM" in your 2Checkout settings.
See: https://knowledgecenter.2checkout.com/Documentation/05Ordering/10Minimize_required_checkout_data
*/
function my_pmpro_twocheckout_short_billing( $request_array ) {
$short_form = array(
"SHORT_FORM" => "1"
);
return array_merge( $short_form, $request_array );
@LMNTL
LMNTL / my_pmpro_js_on_submit.php
Created May 17, 2019 17:21
example of adding Javascript to run after the checkout button is clicked with PMPro
// example of adding Javascript to run after the checkout button is clicked
function my_pmpro_js_on_submit() {
?>
<script>
jQuery(document).ready( function(){
jQuery("#pmpro_form").submit( function(){
alert("hello world!");
});
});
</script>