Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created November 23, 2018 09:31
Show Gist options
  • Select an option

  • Save andrewlimaza/e8c29d047ba6e7dcbe4a8261c7e8404b to your computer and use it in GitHub Desktop.

Select an option

Save andrewlimaza/e8c29d047ba6e7dcbe4a8261c7e8404b to your computer and use it in GitHub Desktop.

Revisions

  1. andrewlimaza created this gist Nov 23, 2018.
    20 changes: 20 additions & 0 deletions pmpro-series-all-access.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    <?php
    /**
    * Give "All Access" to PMPro Series for specific membership level.
    * Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
    */

    function open_series_to_specific_level($hasaccess, $thepost, $theuser, $post_membership_levels) {

    // Bail if the user already has access to a post/page.
    if ( $hasaccess ) {
    return $hasaccess;
    }

    if ( pmpro_hasMembershipLevel( 1 ) && $thepost->post_type == 'pmpro_series' ) { // Change level ID to match levels for all access.
    $hasaccess = true;
    }

    return $hasaccess;
    }
    add_filter("pmpro_has_membership_access_filter", "open_series_to_specific_level", 10, 4);