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_rh_restrict_users.php
Last active March 11, 2022 17:59
Restrict members from accessing members-only content using a checkbox in the profile. Requires PMPro and Register Helper Add On.
<?php
/*
Restrict members from accessing members-only content using a checkbox in the profile.
The button will only show when logged in as an admin.
Requires PMPro and Register Helper Add On to be installed, activated, and configured.
*/
function my_pmprorh_init_restrict()
{
//don't break if Register Helper is not loaded
@LMNTL
LMNTL / my_pmpro_email_headers_admin_emails.php
Last active January 28, 2022 02:49 — forked from strangerstudios/my_pmpro_email_headers_admin_emails.php
BCC an additional email on PMPro admin emails. Works with PMPro Approvals emails.
/*
Add bcc for PMPro admin emails
*/
function my_pmpro_email_headers_admin_emails($headers, $email)
{
$approval_admin = array( "admin_approved", "admin_denied", "admin_notification" );
//bcc emails already going to admin_email
if( strpos($email->template, "_admin") !== false || in_array($email->template, $approval_admin) )
{
@LMNTL
LMNTL / pmpro-limited-time-registration.php
Last active April 7, 2021 03:55
Restrict a membership level to no longer allow sign ups after a given date (limited time offer) using Paid Memberships pro
<?php
/* Checks to see if a registration is happening after a given date; if so, prevent registration and stop new signups for the level/no longer display the level on the levels page
*/
global $pmproml_end_date, $pmproml_limited_level_id;
$pmproml_limited_level_id = 1; // change to the ID of the limited-time membership level
$pmproml_end_date = "2019/04/30"; // change to the date registration ends, in YYYY/MM/DD format
function pmproml_pmpro_registration_date_checks( $value ) {
global $wpdb, $pmproml_end_date, $pmproml_limited_level_id;
@LMNTL
LMNTL / pmpro_add_member_notification.php
Last active January 12, 2021 15:40
Generate checkout email when using Add Member from Admin Add On for Paid Memberships Pro
<?php
/* Generate checkout email when using Add Member from Admin Add On for Paid Memberships Pro
*/
function pmpro_send_member_notification( $user ) {
$pmproemail = new PMProEmail();
$pmproemail->sendCheckoutEmail( $user );
}
add_action( 'pmpro_add_member_added', 'pmpro_send_member_notification', 10, 2 )
@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 / my_pmpro_always_show_renew_levels.php
Created May 20, 2019 20:33
Always show renew links for certain PMPro levels if the member already has that level.
// always show renew links for certain levels if the member already has that level.
function my_pmpro_always_show_renew_levels( $show, $level ){
/*--- change this line to the levels you want to show a renew link---*/
$show_levels = array( 1, 2 );
if( in_array( $level->id, $show_levels ) ) {
$show = true;
}
@LMNTL
LMNTL / my_pmproec_change_confirmation_text
Created July 3, 2019 19:15
Change the text for the confirmation link in the PMPro Email Confirmation Add On welcome email
// change the text for the confirmation link in the PMPro Email Confirmation Add On welcome email
function my_pmproec_change_confirmation_text($body)
{
//change this line to modify the confirmation text
$new_confirmation_text = "Click this link to activate your membership:";
$old_confirmation_text = "IMPORTANT! You must follow this link to confirm your email address before your membership is fully activated:";
$body = str_replace( $old_confirmation_text, $new_confirmation_text, $body );
return $body;
@LMNTL
LMNTL / my_pmprosl_custom_shortcode.php
Created July 24, 2019 00:07
Use a custom social login shortcode with PMPro Social Login (Requires v.3 or above)
//use a custom social login shortcode with PMPro Social Login (Requires v.3 or above)
function my_pmprosl_custom_shortcode($shortcode)
{
// edit this line to change the shortcode displayed on the checkout page
return '[TheChamp-Login title="Use your Social Account to Login"]';
}
add_filter("pmprosl_login_shortcode", "my_pmprosl_custom_shortcode");
@LMNTL
LMNTL / pmpro_gettext_membership_options.php
Last active November 7, 2019 09:56
Hide "View all Membership Options" link on PMPro Account page
function my_gettext_pmpro_hide_view_membership_options($translated_text, $text, $domain)
{
if($domain == "paid-memberships-pro" && $text == "View all Membership Options" )
$translated_text = "";
return $translated_text;
}
add_filter('gettext', 'my_gettext_pmpro_hide_view_membership_options', 10, 3);
@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(