Skip to content

Instantly share code, notes, and snippets.

View indigetal's full-sized avatar

Brandon Meyer indigetal

  • Indigetal WebCraft
  • NC
View GitHub Profile
@indigetal
indigetal / my_pmpro_adjustable_level_cost_v1.5.php
Last active August 4, 2023 16:22
For Paid Memberships Pro - Adjusts the cost of a level at checkout based on the selection of a custom user field for upselling additional options to a plan, accounts for recurring plans, and adjust the cost based on if it's a monthly or annual plan (fixes and expands on the code snippet at https://www.paidmembershipspro.com/multiple-membership-l…
<?php
function my_pmpro_adjustable_level_cost($level)
{
// Specify the monthly and annual levels
$monthly_levels = array(1, 2);
$annual_levels = array(3, 4);
// Set the field name here
$field_name = 'field_name';
@indigetal
indigetal / my_pmpro_adjustable_level_cost_v1.4.php
Last active August 4, 2023 16:22
For Paid Memberships Pro - Adjusts the cost of a level at checkout based on the selection of a custom user field for upselling additional options to a plan and accounts for recurring plans (fixes and expands on the code snippet at https://www.paidmembershipspro.com/multiple-membership-levels-per-user-pmpro-workarounds/)
<?php
function my_pmpro_adjustable_level_cost($level)
{
// Set the field name here
$field_name = 'field_name';
// Set the available field options and their extra fee here
$options = array(
'option1' => 100,
'option2' => 200,
@indigetal
indigetal / my_pmpro_custom_redirects.php
Last active August 8, 2023 02:44
Works with PMPro and the Multiple Memberships Per User Addon. Create 2 membership plan pages using Advanced Levels Page Shortcode Addon for 2 level groups, called group 1 and group 2 here. Redirects users to the relevant membership plan page if the user does not have the membership level that corresponds to the restricted page. Allows users to p…
<?php
// Restrict access to certain pages based on level group:
function my_pmpro_custom_redirects() {
// The Level ID's associated with each "Level Group"
$group_one = array('1', '2', '3');
$group_two = array('4', '5', '6');
// The pages to be restricted
$page_names = array('group-1-access', 'group-2-access');