Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
strangerstudios / my_pmpro_user_has_cap.php
Created May 19, 2016 13:39
Only let this specific users access the Paid Memberships Pro Reports admin page.
<?php
function my_pmpro_user_has_cap($allcaps, $caps, $args, $user)
{
if($user->ID !== 1)
unset($allcaps['pmpro_reports']);
return $allcaps;
}
add_filter('user_has_cap', 'my_pmpro_user_has_cap', 10, 4);
@greathmaster
greathmaster / checkout.php
Created May 18, 2016 16:23
Custom PMPro checkout page template. Replaces "State" billing field text field with a dropdown for longform addresses.
<?php
/*
Custom checkout.php page for PMPro.
Replaces "State" billing field text field with a dropdown for longform addresses.
Based on PMPro v1.8.9.1.
*/
global $gateway, $pmpro_review, $skip_account_fields, $pmpro_paypal_token, $wpdb, $current_user, $pmpro_msg, $pmpro_msgt, $pmpro_requirebilling, $pmpro_level, $pmpro_levels, $tospage, $pmpro_show_discount_code, $pmpro_error_fields;
global $discount_code, $username, $password, $password2, $bfirstname, $blastname, $baddress1, $baddress2, $bcity, $bstate, $bzipcode, $bcountry, $bphone, $bemail, $bconfirmemail, $CardType, $AccountNumber, $ExpirationMonth,$ExpirationYear;
/**
@strangerstudios
strangerstudios / pmpro_cron_expire_memberships_now.php
Created May 12, 2016 15:26
Force the Paid Memberships Pro expiration script to run immediately.
/*
Force the PMPro expiration script to run immediately.
Add this code into a custom plugin, then login as an admin and visit /?expirenow=1
*/
function pmpro_cron_expire_memberships_now() {
if(!empty($_REQUEST['expirenow']) && current_user_can('manage_options')) {
echo "Forcing expirations now<hr />";
pmpro_cron_expire_memberships();
exit;
@strangerstudios
strangerstudios / my_pmpro_signup_shortcode_example.php
Last active March 21, 2018 14:48
Example of the [pmpro_signup] shortcode
[pmpro_signup level="1" short="false" title="Member Signup" intro="Enter your email and create a password for access."]
@strangerstudios
strangerstudios / my_pmpro_widget_display_callback.php
Last active August 22, 2018 14:55
Hide widgets by sidebar ID on members only content when the current user does not have access.
<?php
/*
Update line 8 with the array of sidebar IDs you want to filter.
Add this code to your active theme's functions.php or a custom plugin.
*/
function my_pmpro_widget_display_callback($instance, $widget, $args) {
$hide_sidebars_array = array('sidebar-1','sidebar-2');
global $post;
if( is_user_logged_in() && function_exists('pmpro_has_membership_access') && !pmpro_has_membership_access($post->ID)) {
@strangerstudios
strangerstudios / pmpro-member-count-shortcode.php
Last active April 13, 2021 04:32
PMPro Member Count Shortcode
<?php
/*
Plugin Name: PMPro Member Count Shortcode
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Show the number of members in a level w/a status
Version: .2
Author: Thomas Sjolshagen @ Stranger Studios <[email protected]>, strangerstudios
Author URI: http://www.strangerstudios.com
*/
function pmpro_member_count_shortcode( $attrs = null )
@strangerstudios
strangerstudios / my_gettext_pmproap_changes.php
Created April 10, 2016 23:18
Change some of the text strings in PMPro Addon Packages via the WP gettext filter.
<?php
function my_gettext_pmproap_changes($translated_text, $text, $domain)
{
if($domain == "pmproap" && $text == "Purchase this Content (%s)")
$translated_text = "Purchase Now for %s";
elseif($domain == "pmproap" && $text == "Choose a Membership Level")
$translated_text = "Choose a Plan";
return $translated_text;
}
@strangerstudios
strangerstudios / my_pmpro_confirmation_url.php
Created April 8, 2016 14:47
Example of using the pmpro_confirmation_url filter to change the PMPro confirmation page for new users.
function my_pmpro_confirmation_url($url, $user_id, $level) {
$already_member = get_user_meta($user_id, 'already_member', true);
if(!$already_member) {
update_user_meta($user_id, 'already_member', 1);
$url = home_url('/my-dashboard');
}
return $url;
}
add_filter('pmpro_confirmation_url', 'my_pmpro_confirmation_url');
@strangerstudios
strangerstudios / my_pmpro_email_checkout_renewal.php
Created April 5, 2016 20:22
Use a custom checkout_renewal.html email template for renewal purchases in Paid Memberships Pro
/*
Use a custom checkout_renewal.html email template for renewals.
Add this code to a custom plugin.
Make sure there is a folder /email/ in the plugin folder.
Add a file /email/checkout_renewal.html in that email folder.
*/
function my_pmpro_email_checkout_renewal($email) {
@strangerstudios
strangerstudios / pmpro_expiration_date_shortcode_bbpress_profile.php
Last active June 23, 2023 14:32
Show a member's expiration date on bbPress profile page.
/*
Use this recipe in conjunction with PMPro bbPress Add On
plus this gist: https://gist.github.com/strangerstudios/ff354cd84254b856ef5194c4259c9e38
Add this code to your active theme's functions.php or a custom plugin.
*/
function pmpro_expiration_date_shortcode_output() {
$user_id = bbp_get_user_id( 0, true, false );
?>