Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Last active September 19, 2024 07:55
Show Gist options
  • Save andrewlimaza/85030b4aa6da45c6d3d3fc8ede3f2ed1 to your computer and use it in GitHub Desktop.
Save andrewlimaza/85030b4aa6da45c6d3d3fc8ede3f2ed1 to your computer and use it in GitHub Desktop.
Hide checkout button for PMPro when user is logged-out.
<?php
/**
* Hide the PMPro Checkout button when user isn't logged-in.
* To add this code to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_hide_checkout_button() {
// Bail if PMPro isn't active or not the checkout page.
if ( ! function_exists('pmpro_is_checkout' ) || ! pmpro_is_checkout() ) {
return;
}
if ( ! is_user_logged_in() ) {
// Hide the checkout button if the user is not logged in.
?>
<style>
.pmpro_form_submit {
display: none !important;
}
</style>
<?php
}
}
add_action( 'wp_footer', 'my_hide_checkout_button' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment