Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kimwhite/a9754fecf947e1b0b93d22a7c9bc67e0 to your computer and use it in GitHub Desktop.
Save kimwhite/a9754fecf947e1b0b93d22a7c9bc67e0 to your computer and use it in GitHub Desktop.
Only show the discount code fields if member is logged in
<?php
/**
* Only show the discount code fields if a code is passed in via URL paramter
*
* 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 hide_my_pmpro_show_discount_code_not_member( $show ) {
if ( empty( $_REQUEST[ 'discount_code' ] ) && ! is_user_logged_in() ) {
$show = false;
}
return $show;
}
add_filter( 'pmpro_show_discount_code', 'hide_my_pmpro_show_discount_code_not_member');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment