Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an filter to assign membership immediately #116

Open
dparker1005 opened this issue Jun 7, 2024 · 2 comments
Open

Add an filter to assign membership immediately #116

dparker1005 opened this issue Jun 7, 2024 · 2 comments

Comments

@dparker1005
Copy link
Member

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

@gnpwdr-mike
Copy link

gnpwdr-mike commented Sep 13, 2024

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
Copy link
Member Author

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:
strangerstudios/pmpro-snippets-library#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants