Skip to content

Instantly share code, notes, and snippets.

Avatar
🍕
Working hard reviewing and deploying code

Scott Kingsley Clark sc0ttkclark

🍕
Working hard reviewing and deploying code
View GitHub Profile
@sc0ttkclark
sc0ttkclark / givewp-multisite-cookie.php
Last active Jul 22, 2021
Maybe set the GiveWP cookie needed for the Donor Dashboard on Multisite subsites (when GiveWP is not network activated)
View givewp-multisite-cookie.php
@sc0ttkclark
sc0ttkclark / pmpro-inherit-levels.php
Last active Jun 11, 2021
PMPro snippet to allow inherited levels based on a configuration. If a member has any level that matches, they will automatically inherit access to other membership levels as configured.
View pmpro-inherit-levels.php
<?php
/**
* The configuration of inherited levels to use.
*
* @return array List of inherited level mapping.
*/
function my_pmpro_inherit_levels() {
// @todo Modify this list based on your needs.
return [
@sc0ttkclark
sc0ttkclark / pmpro-elementor-fix-redirect.php
Created Jun 9, 2021
PMPro compatibility for the Elementor page builder editor screen
View pmpro-elementor-fix-redirect.php
<?php
/**
* Maybe turn off the redirect if we are on the Elementor editor screen logged in as someone who can edit the post.
*
* @param string $redirect_to The URL to redirect to.
*
* @return string The URL to redirect to.
*/
function my_pmpro_elementor_fix_redirect( $redirect_to ) {
@sc0ttkclark
sc0ttkclark / pmpro-wpforms-snippets.php
Last active Jun 8, 2021
PMPro integration for WPForms that adds "Require Membership" settings to the "General" settings of a Form. Also has integration with PMPro Series Add-On to prevent access to forms if not yet available in the series flow.
View pmpro-wpforms-snippets.php
<?php
/**
* Add output that explains that the person does not have access to this form.
*
* Customize this to fit your needs!
*/
function my_pmpro_wpform_locked_message() {
// Set your level ID here so they know where to go to sign up. Non-existent ID will just send them to the Membership Levels page.
$level_id = 9999999;
@sc0ttkclark
sc0ttkclark / pmpro-addon-checkout-email-template.php
Last active Jun 21, 2021
This snippet enables a custom template to be used for when a member completes checkout for an addon. Look for "Checkout - Paid - Addon" in the template list. REQUIRES: PMPro, PMPro Addon Packages, and PMPro Email Templates Add On
View pmpro-addon-checkout-email-template.php
<?php
/**
* Register the custom checkout template for addon package purchases.
*
* @param array $templates The list of templates.
*
* @return array The list of templates.
*/
function my_addon_checkout_template_register_template( $templates ) {
@sc0ttkclark
sc0ttkclark / pmpro-user-page-content-filter-per-level.php
Created Jun 4, 2021
Use a filter to adjust the content based on Membership Level for the User Page that is created with PMPro and the User Pages Add-On.
View pmpro-user-page-content-filter-per-level.php
<?php
/*
* When the user page is created, add some content based on membership level.
*
* @param array $postdata The data to use when saving the new user page.
* @param WP_User $user The user the page is being created for.
* @param object $level The membership level object.
*
* @return array The data to use when saving the new user page.
*/
@sc0ttkclark
sc0ttkclark / login-link.html
Created Jun 3, 2021
Login link example for PMPro
View login-link.html
@sc0ttkclark
sc0ttkclark / hide_my_pods_item_filter_post_types.php
Created Apr 27, 2021 — forked from kimcoleman/hide_my_pods_item_filter_post_types.php
Hide specific post types created using the Pods framework from searches and archives if membership is required to access.
View hide_my_pods_item_filter_post_types.php
<?php
/**
* Hide the 'my_pods_item' post type from searches and archives if membership is required to access.
* Update the $post_types[] array with one or more pod names you need to protect.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
@sc0ttkclark
sc0ttkclark / snippet.php
Created Apr 2, 2021
Snippet for TEC 5.5.0 to solve the problem prior to hotfix
View snippet.php
<?php
add_action( 'tribe_events_pre_rewrite', static function( Tribe__Events__Rewrite $rewrite ) {
if ( '5.5.0' !== Tribe__Events__Main::VERSION ) {
return;
}
Tribe__Tickets__Tickets_View::instance()->add_permalink( $rewrite );
} );
@sc0ttkclark
sc0ttkclark / example.php
Last active Mar 31, 2021 — forked from skyshab/example.php
Allow all IAC attendees to view protected content
View example.php
<?php
add_filter( 'tribe_tickets_shortcode_can_see_content', static function( $can_see_content, $filter_args ) {
// Only run our logic below if the user is logged in or if they cannot currently see the content.
if ( ! is_user_logged_in() || $can_see_content ) {
return $can_see_content;
}