Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
@kimcoleman
kimcoleman / pmpro_pmpro_not_logged_in_text_filter.php
Created May 14, 2020 11:07
Edit Teaser Messages Depending on Content
<?php
/**
* Edit Teaser Messages Depending on Content
*
*/
function pmpro_pmpro_not_logged_in_text_filter( $text ) {
global $post;
$access = pmpro_has_membership_access( $post->ID, NULL, true );
$level_ids = $access[1];
@kimcoleman
kimcoleman / redirect_non_members_to_levels_page.php
Last active April 3, 2021 03:11 — forked from andrewlimaza/redirect_users_to_a_new_page.php
Redirect non-members to the Membership Levels page in PMPro if they do not have a membership level.
<?php
/**
* Redirect non-members to the Membership Levels page if they do not have a membership level.
*
* 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/
*
*/
@andrewlimaza
andrewlimaza / remove-vp-pricing-discounut-code.php
Last active September 23, 2020 15:25
Remove variable pricing check when discount code is applied. [Paid Memberships Pro]
<?php
/**
* Remove variable pricing requirements if a discount code is set.
* Follow this guide to add this code snippet to your site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
* Visit www.paidmembershipspro.com for more information.
*/
function my_pmpro_remove_vp_check_discount_code( $continue ) {
global $pmpro_level;
@ideadude
ideadude / my_pmpro_forward_ipn.php
Last active August 7, 2020 16:01
Forward PMPro IPN messages from one site to another.
/**
* Forward PMPro IPNs to another PMPro site.
*/
function my_pmpro_forward_ipn() {
$fp = wp_remote_post( 'https://theothersite.com/wp-admin/admin-ajax.php?action=ipnhandler', $_POST );
}
add_action('wp_ajax_nopriv_ipnhandler', 'my_pmpro_forward_ipn', 5);
add_action('wp_ajax_ipnhandler', 'my_pmpro_forward_ipn', 5);
<?php
/**
* Trigger admin activity email.
*
* To send a test email, go to yoursite.com/?test_admin_activity_email=1
*/
function pmpro_test_activity_email() {
if ( ! empty( $_REQUEST['test_admin_activity_email'] ) ) {
$email = new PMPro_Admin_Activity_Email;
@andrewlimaza
andrewlimaza / require-ip-location-match.php
Last active April 3, 2021 03:28
Require user's IP location to be the same as their billing country field [Paid Memberships Pro]
<?php
/**
* Require user's checking out for any level that requires billing to match their IP address with billing country address fields.
* Only works with levels that require billing fields.
* Please install and activate the following plugin - https://wordpress.org/plugins/geoip-detect/
*/
function pmpro_require_location_match_IP( $continue ) {
global $pmpro_requirebilling;
@ideadude
ideadude / my_pmpro_bp_lockdown_all_bp.php
Created April 1, 2020 16:28
Allow non-members to view the BuddyPress profile pages even if you are "locking down all of BuddyPress".
/**
* This gist will disable the default behavior in PMPro BuddyPress 5.2.5 or earlier,
* which would redirect users away from the BP profile pages if you had
* "all of BuddyPress" locked down for non-members or members of a specific level.
*
* We might address this in future versions of the Add-On, but for now, you can use
* this gist. Add it to a Code Snippet or a custom plugin.
*/
// First disable the default PMPro BuddyPress behavior.
<?php
/**
* We'll add in a check to see which membership level was purchased.
* We can then specify which webhook each level should send data to.
* If it doesn't meet the criteria of our check, we'll use the default
* in the settings page.
* That URL is then added to the $data array
*/
function mypmpro_multiple_zapier_webhooks_after_order( $data, $order, $user_id ){
@JarrydLong
JarrydLong / pmpro-remove-user-membership-order-data.php
Created March 16, 2020 15:15
Removes a user's membership and order data either by manually adding in a query param, or when deleting a user through /wp-admin/
<?php
/**
* Remove user data manually by adjusting the ID's in the array, or adding them into a
* query param by setting it to /?reset_test_accounts=true&accounts=2,3
* This works well if you've deleted the user accounts already and want to remove the
* first few users you'd initially tested with
*/
function pmpro_remove_test_accounts( $user_id = null ){
if( isset( $_REQUEST['reset_test_accounts'] ) && $_REQUEST['reset_test_accounts'] == 'true' ){
@andrewlimaza
andrewlimaza / load-session-earlier.php
Created March 5, 2020 11:28
Load session earlier [Paid Memberships Pro]
<?php
/**
* Load session earlier to remove warning.
* Add code to your site following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_load_pmpro_sessions_earlier() {
remove_action('pmpro_checkout_preheader_before_get_level_at_checkout', 'pmpro_start_session' );
}
add_action( 'init', 'my_load_pmpro_sessions_earlier' );
add_action('init', 'pmpro_start_session' );