Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbrocks/22362ae5294cb83708499948b3aae045 to your computer and use it in GitHub Desktop.
Save pbrocks/22362ae5294cb83708499948b3aae045 to your computer and use it in GitHub Desktop.
Use pmpro_getfile_before_error to tell PMPro to do something else besides send a 503 when accessing a member file. Requires PMPro 1.7.15+
<?php // do not include in Customizations plugin
/**
* Redirect to the levels page when users try to access protected files in PMPro.
*
* Add this code to your customizations plugin file.
*
* Learn about protecting files with PMPro here:
* https://www.paidmembershipspro.com/locking-down-protecting-files-with-pmpro/
*/
function my_pmpro_getfile_before_error( $filename ) {
wp_redirect( pmpro_url( 'levels' ) );
exit; // need to exit at end of function to avoid sending the 503
}
add_action( 'pmpro_getfile_before_error', 'my_pmpro_getfile_before_error' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment