Skip to content

Instantly share code, notes, and snippets.

View dparker1005's full-sized avatar

David Parker dparker1005

  • Stranger Studios
View GitHub Profile
@dparker1005
dparker1005 / discount_with_check.php
Last active June 12, 2019 19:19
Discounts the price of a membership by $50 when a user pays by check using Paid Memberships Pro and PMPro Pay by Check Add-On. For use in PMPro Customizations Plugin.
<?php
/**
* If a user paid by check, give them a $50 discount.
*/
function my_pmpro_discount_with_check( $level ) {
if ( 'check' === $_REQUEST['gateway'] ) {
$level->initial_payment = $level->initial_payment - 50;
// $level->billing_amount = $level->billing_amount - 50; //to update recurring payments too
@dparker1005
dparker1005 / change_account_management_text.php
Created June 13, 2019 12:59
Updated snippet from user which changes 'Account Management' to 'Password Management' on a user's WordPress profile in addition to the snippet's original functionality.
<?php
function my_gettext_membership( $output_text, $input_text, $domain ) {
global $pagenow;
if ( ! is_admin() && 'pmproarc' === $domain ) {
$output_text = preg_replace( '/Yes, renew at.+$/', 'Allow recurring payments using PayPal', $output_text );
}
if ( 'profile.php' === $pagenow ) {
$output_text = str_replace( 'Account Management', 'Password Management', $output_text );
}
@dparker1005
dparker1005 / disable_redirect_to_page.php
Created June 14, 2019 13:36
Prevents wp_redirect to redirect to a specified page.
<?php
/**
* Disable Redirection to Specific Page
*/
function my_wp_redirect($location) {
// TODO: Change '10' to the page id that should not be redirected to
$page_id = 10;
@dparker1005
dparker1005 / pmproama_send_invoice.php
Last active June 14, 2019 16:05
Send 'invoice' email notification when user is added using Add Member Admin Add on.
<?php
// Add this function to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
function pmproama_send_invoice( $user_id ) {
$order = new MemberOrder();
$order->getLastMemberOrder( $user_id );
$pmproemail = new PMProEmail();
$pmproemail->sendInvoiceEmail( get_userdata( $user_id ), $order );
@dparker1005
dparker1005 / change_stripe_description.php
Created June 17, 2019 18:38
Changes the order description sent to Stripe from PMPro checkout.
<?php
function my_pmpro_change_stripe_description( $description, $MemberOrder ) {
return 'This is my new description.';
}
add_filter("pmpro_stripe_order_description", "my_pmpro_change_stripe_description", 10, 2);
@dparker1005
dparker1005 / add_personal_data_fields.php
Last active June 21, 2019 19:37
Adds user meta fields to 'Export Personal Data' and 'Delete Personal Data' for GDPR compliance, particularly with Register Helper add-on
<?php
function my_pmpro_add_personal_data_fields( $fields ) {
$fields['meta_name'] = 'Pretty Meta Name';
// Copy the above line for each field you want to include.
return $fields;
}
add_filter( 'pmpro_get_personal_user_meta_fields', 'my_pmpro_add_personal_data_fields' );
function my_pmpro_add_personal_data_fields_to_erase( $fields ) {
@dparker1005
dparker1005 / my_pmpro_sws_levels_page_hide_banner.php
Created July 2, 2019 14:57
Hides the PMPro SWS banner while on the levels page
<?php
function my_pmpro_sws_levels_page_hide_banner() {
global $pmpro_pages;
if ( is_page( $pmpro_pages['levels'] ) ) {
?>
<script>
var banners = document.getElementsByClassName("pmpro_sws_banner ");
if(banners.length > 0) {
banners[0].style.display = "none";
@dparker1005
dparker1005 / my_pmproarc_move_checkout_field.php
Last active July 11, 2019 13:14
Currently, PMPro Auto-Renewal Checkbox puts its checkout box at the bottom of the page. This will move it to after the level cost. There are two different code options for accomplishing this: a simple one and one that lets you customize the checkout box.
<?php
// Use the below code to simply move the field
// ===============================================================================
function my_pmproarc_move_checkout_field() {
remove_action('pmpro_checkout_boxes', 'pmproarc_pmpro_checkout_boxes', 15);
add_action( 'pmpro_checkout_after_level_cost', 'pmproarc_pmpro_checkout_boxes', 5 );
}
add_action( 'init', 'my_pmproarc_move_checkout_field' );
// ===============================================================================
@dparker1005
dparker1005 / my_pmpro_add_name_placeholder.php
Last active July 29, 2019 16:30
Adds placeholder to name fields during checkout
<?php
// Copy from below this line
function my_pmpro_add_name_placeholder() {
?>
<script>
jQuery("#bfirstname").attr("placeholder", "Type your first name here...");
jQuery("#blastname").attr("placeholder", "Type your last name here...");
</script>
@dparker1005
dparker1005 / pmproaffl_offsite_billing_fields.php
Created July 31, 2019 14:01
When using "PMPro Capture Name & Address for Free Levels or for Offsite Gateway", this Gist will only show billing fields for offsite gateways and not for free levels.
<?php
// Copy from below here
/**
* Stop adding billing fields to everywhere
*/
function my_pmproaffl_init() {
remove_action( 'init', 'my_pmproaffl_init_include_address_fields_at_checkout', 30 );
}