Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
strangerstudios / wp_footer_asterisk_fix.php
Last active Jun 16, 2022
Move required asterisks into the field labels of the Paid Memberships Pro checkout page.
View wp_footer_asterisk_fix.php
@strangerstudios
strangerstudios / my_pmpro_registration_checks.php
Created Apr 14, 2015
Require a certain level before registering for another level with Paid Memberships Pro.
View my_pmpro_registration_checks.php
/*
Require a certain level before registering for another level.
Add this code to your active theme's functions.php or
a custom plugin.
*/
function my_pmpro_registration_checks($okay)
{
//only check if things are okay so far
if($okay)
{
@strangerstudios
strangerstudios / gist:4027538
Created Nov 6, 2012
Hide the confirm email and confirm password fields from the Paid Memberships Pro checkout page.
View gist:4027538
/*
Don't show confirm password or email fields on the checkout page.
Add this code to your active theme's functions.php or a custom plugin.
*/
add_filter("pmpro_checkout_confirm_password", "__return_false");
add_filter("pmpro_checkout_confirm_email", "__return_false");
@strangerstudios
strangerstudios / pmpro-limit-members-per-level.php
Last active May 19, 2022 — forked from greathmaster/pmpro-limit-members-per-level.php
Limit the number of total sign ups for a given membership level
View pmpro-limit-members-per-level.php
<?php
/*
Set a maximum number of members allowed to register for a membership level.
Add this code to a plugin for PMPro Customizations.
Set the "Maximum" for a level on the Memberships > Membership Levels > Edit Level admin page.
*/
function pmproml_pmpro_save_membership_level( $level_id) {
if( $level_id <= 0 ) {
@strangerstudios
strangerstudios / my_pmpro_dashboard_report.php
Last active Apr 14, 2022 — forked from andrewlimaza/my_custom_dashboards.php
Show Membership Reports on the WordPress Admin Dashboard
View my_pmpro_dashboard_report.php
<?php
/*
Show Members Reports on the WordPress Admin Dashboard.
Update the my_pmpro_dashboard_report() function to remove or add core or custom reports.
*/
//Create a Dashboard Reports widget for Paid Memberships Pro
function add_my_report_dashboard() {
if( ! defined( 'PMPRO_DIR' ) || ! current_user_can( 'manage_options' ) )
{
@strangerstudios
strangerstudios / pmpro_after_change_membership_level_default_level.php
Last active Apr 7, 2022
Place a PMPro member in another level when they cancel... unless they are cancelling from that level.
View pmpro_after_change_membership_level_default_level.php
/*
When users cancel (are changed to membership level 0) we give them another "cancelled" level.
Can be used to downgrade someone to a free level when they cancel.
Will allow members to the "cancel level" to cancel from that though.
*/
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;
@strangerstudios
strangerstudios / my_pmpro_checkout_start_date.php
Last active Mar 14, 2022
PMPro Adjust start date to the first following Sunday.
View my_pmpro_checkout_start_date.php
/*
Adjust start date to the first following Sunday
*/
//at checkout
function my_pmpro_checkout_start_date($startdate)
{
//which day is it
$checkout_day = date("N");
//days to sunday
@strangerstudios
strangerstudios / pmpro_network_new_site.php
Created Oct 22, 2015
Change users to editor on new sites created for them with PMPro and PMPro Network.
View pmpro_network_new_site.php
function pmpro_network_new_site_editor($blog_id, $user_id)
{
//switch to new blog
switch_to_blog($blog_id);
//change user's role on blog to "editor"
$wp_user_object = get_userdata($user_id);
$wp_user_object->set_role('editor');
//switch back to main blog
@strangerstudios
strangerstudios / my_pmpro_members_list_csv_extra_columns.php
Last active Mar 10, 2022
Add a custom field to the members list CSV export in Paid Memberships Pro.
View my_pmpro_members_list_csv_extra_columns.php
<?php
/*
Add employer, title, and department columns to the members list CSV export.
Just add this code to your functions.php or a custom plugin.
The first function here defines the column headers and a callback function for each column.
*/
function my_pmpro_members_list_csv_extra_columns($columns)
{
$columns["employer"] = "my_extra_column_employer";
@strangerstudios
strangerstudios / my_cpt_404_redirects.php
Created Feb 20, 2015
Use template_redirect and post_type_link filters in WordPress to remove the CPT slug from the front of CPT URLs.
View my_cpt_404_redirects.php
/*
If 404 on a post, look for a gallery or portfolio with the same slug.
Borrows from: https://wordpress.stackexchange.com/a/45081/3652
*/
function my_cpt_404_redirects($template)
{
if(is_404())
{
//see if we know the exact post ID