strangerstudios / pmpro-pay-by-check

Add a "Pay by Check" option to PMPro levels, and keep members in "pending" status until an admin changes the order status.
https://www.paidmembershipspro.com/add-ons/pmpro-pay-by-check-add-on/
11 stars 27 forks source link

Add an filter to assign membership immediately #116

Open dparker1005 opened 4 months ago

dparker1005 commented 4 months ago

Some sites don't want users to have to wait until the first check is received to get membership access.

gnpwdr-mike commented 4 weeks ago

Leaving a note for anyone else that this gist by @dparker1005 provides a current solution to the issue above.

https://gist.github.com/dparker1005/cf8d8a02059906197f95fd26ae229f5a#file-my_unhook_pmpropbc_use_custom_gateway_class-php

<?php

// Copy from below this line.

/**
 * Unhooks using the custom Check gateway class in the PMPro PBC plugin.
 *
 * This removes the "delayed checkout" functionality and gives users membership
 * access immediately after checkout. This is not typically reccomended as it is
 * not compatible with many PMPro Add Ons.
 *
 * This code recipe also may not be supported in future versions of PMPro Pay By Check.
 * Use this code recipe at your own risk.
 *
 * 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/
 */
function my_unhook_pmpropbc_use_custom_gateway_class() {
    remove_filter( 'pmpro_order_gateway_object', 'pmpropbc_use_custom_gateway_class' );
    remove_filter( 'pmpro_subscription_gateway_object', 'pmpropbc_use_custom_gateway_class' );
}
add_action( 'init', 'my_unhook_pmpropbc_use_custom_gateway_class' );
dparker1005 commented 2 weeks ago

I have also put together a code snippet here that will allow users to access restricted content for a level when they have a pending order for that level: https://github.com/strangerstudios/pmpro-snippets-library/pull/203

Note that the level still won't actually be given until the check is received. This code recipe will only allow access when the “Requires Membership” checkbox is checked for a page/post, not in situations where individual blocks are restricted for example.