Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
@ipokkel
ipokkel / open_specific_new_posts_to_non_members.php
Last active April 12, 2021 22:37 — forked from strangerstudios/open_new_posts_to_non_members.php
PMPro Customizations to allow non-members to view specified restricted posts if they are less than 30 days old.
<?php
/**
* This recipe allows non-members to view specific restricted posts
* if they are less than 30 days old.
*
* To set which posts to unlock set the post id's in the array of
* the $posts_to_unlock variable
* Change the '-30 Days' below if you'd like to allow access for longer or shorter.
*
* You can add this recipe to your site by creating a custom plugin
@ipokkel
ipokkel / ConvertArrayOfObjectSample.php
Created May 23, 2020 06:49 — forked from esilvajr/ConvertArrayOfObjectSample.php
This is a basic solution when we need to convert a array of objects into a multidimensional array in PHP.
<?php
/**
* This is just a class for our tests
*/
class Foo
{
/**
* @var foo
*/
public $foo = 'foo';
@ipokkel
ipokkel / one_time_trial_delay_pmpro_registration_checks.php
Last active May 13, 2020 05:29 — forked from kimcoleman/one_time_trial_delay_pmpro_registration_checks.php
Offer one-time trials using the Subscription Delays Add On
<?php
/**
* This recipe stores data when a user checks out for a level.
* If that user tries to checkout for the same level, the Subscription Delay is removed.
* The user is instead charged for their first subscription payment at checkout.
*
* 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/
@ipokkel
ipokkel / prorate-fiscal-year-per-quarter.php
Last active August 11, 2020 08:26 — forked from messica/my_pmpro_checkout_level.php
Prorate initial payment per quarater based on subscription delay for a yearly (fiscal) recurring subscription
<?php
/**
* This recipe was moved to
* https://gist.github.com/ipokkel/b89417247fedc473515e9e980fc34996
*/
#
# Verify captcha
$post_data = http_build_query(
array(
'secret' => CAPTCHA_SECRET,
'response' => $_POST['g-recaptcha-response'],
'remoteip' => $_SERVER['REMOTE_ADDR']
)
);
$opts = array('http' =>
@ipokkel
ipokkel / generate_member_number.php
Last active March 13, 2020 13:41 — forked from strangerstudios/generate_member_number.php
Generate a "Member Number" for WordPress users and show it on the PMPro account page.
<?php
/*
Member Numbers
* Change the unique_alphanumeric_member_number function if your member number needs to be in a certain format.
* Member numbers are generated when users are registered or when the membership account page is accessed for the first time.
*/
// randomize alphabetical string
@ipokkel
ipokkel / hide_prices_woo_pmpro.php
Last active February 26, 2020 03:31 — forked from andrewlimaza/hide_prices_woo_pmpro.php
Hide prices + add to cart button for non members Paid Memberships Pro and WooCommerce
<?php
/**
* This recipe will only allow approved users of a certain levels to shop.
* Update line 25 with the membership level IDs to allow into the store.
*
* 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/
@ipokkel
ipokkel / my-default-wp-user-checkout-fields.php
Last active March 18, 2021 06:18 — forked from strangerstudios/my_default_wp_user_checkout_fields.php
Collect the default WordPress Website URL and Biographical description during Membership Checkout with Register Helper fields and save with custom callback using save_function for RH
<?php
/**
* This recipe adds Website and Biographical Info to the Membership Checkout.
*
* 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/
*/
@ipokkel
ipokkel / dynamic_pmpro_levels_array.php
Created February 3, 2020 04:38 — forked from kimcoleman/dynamic_pmpro_levels_array.php
Dynamically display certain levels on the Membership Levels page based on the current user's active level
<?php
/**
* Dynamically display certain levels on the Membership Levels page based on the current user's active level
* This example allows you to show/hide specific levels on the Membership Levels page.
*/
function dynamic_pmpro_levels_array( $levels ) {
// Get all the levels
$levels = pmpro_getAllLevels( false, true );
// remove levels 1, 5, 6, and 7 user has level 1.
@ipokkel
ipokkel / redirect-login-last-post-custom.php
Last active January 30, 2020 11:19 — forked from ideadude/my_redirect_to_last_post_id.php
On WordPress login, redirect to the last post you were viewing or custom page if no last page available
<?php
/**
* On login, redirect to the last post viewed or custom page if no last page available.
* Add this code into a custom plugin.
* Note that many themes and plugins hook into login_redirect.
* Whichever hook has the highest priority will be the last call
* on where to redirect. The priority below is set to 20.
* Note also that some URLs/pages may note be "posts"
* and may not have an ID we can track.