Skip to content

Instantly share code, notes, and snippets.

View ipokkel's full-sized avatar

Theuns Coetzee ipokkel

View GitHub Profile
/* Main layout: arrange all my address fields in 2 columns */
#pmpro_form_fieldset-my-address .pmpro_form_fields {
display: flex !important;
flex-wrap: wrap !important;
flex-direction: row !important;
gap: 20px;
}
/* Each field gets half-width column */
#pmpro_form_fieldset-my-address .pmpro_form_field {
@ipokkel
ipokkel / my-pmpro-set-default-vat-country-on-checkout.php
Created July 22, 2025 07:21
Set the default VAT country based on the default PMPro country at checkout.
<?php
function my_pmpro_set_default_vat_country_on_checkout() {
// Only run on checkout page if a country isn't already set.
if ( ! function_exists( 'pmpro_is_checkout' ) || ! pmpro_is_checkout() || ! empty( $_REQUEST['eucountry'] ) || ! empty( $_SESSION['eucountry'] ) ) {
return;
}
// Get the default country and the EU countries.
$default_country = apply_filters( 'pmpro_default_country', '' );
global $pmpro_european_union;
@ipokkel
ipokkel / pmpro-member-shortcode-field-all-memberships-names.php
Created July 7, 2025 15:22
Add the `all_membership_names` field for the `[pmpro_member]` shortcode to display a comma separated list of all the active membership level names for the current user.
<?php
/**
* This recipe adds the custom field all_memberships_names for the [pmpro_member] shortcode
* that will display a comma separated list of all the user's membership level(s).
*
* Example Usage of [pmpro_member field="all_memberships_names"]
*
* 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.
/* change select button colors for level 3 for non level 3 members */
body.pmpro-levels:not(.pmpro-body-has-level-3) #pmpro_level-3 .pmpro_level-select .pmpro_btn.pmpro_btn-select{
background-color: rgb(0, 165, 157);
border-color: rgb(0, 165, 157);
}
body.pmpro-levels:not(.pmpro-body-has-level-3) #pmpro_level-3 .pmpro_level-select .pmpro_btn.pmpro_btn-select:hover {
background-color: rgb(0, 200, 190);
border-color: rgb(0, 200, 190);
}
/* hide directory search form, company and company role */
body:not(.pmpro-body-has-level-2):not(.pmpro-body-has-level-3) form.pmpro_member_directory_search,
body:not(.pmpro-body-has-level-2):not(.pmpro-body-has-level-3) .pmpro_member_directory .pmpro_card .pmpro_member_profile_field-company,
body:not(.pmpro-body-has-level-2):not(.pmpro-body-has-level-3) .pmpro_member_directory .pmpro_card .pmpro_member_profile_field-company_role {
display: none;
}
/* show directory search form for level 2 and 3 members */
body.pmpro-body-has-level-2 form.pmpro_member_directory_search,
body.pmpro-body-has-level-3 form.pmpro_member_directory_search {
<?php
/**
* Cancel membership level and subscription at payment gateway when a member is denied.
*
* 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_pmpro_cancel_subscription_on_denial( $user_id, $level_id ) {
@ipokkel
ipokkel / redirect-old-members-to-membership-account.php
Created May 21, 2025 10:23
Redirect old members to the membership account page on login.
<?php
/**
* Redirect old members to the membership account page on login.
*
* 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_login_redirect_old_members_to_membership_account( $redirect_to, $request, $user ) {
<?php
/**
* Flush WordPress user meta cache.
*
* Add the flushmetacache parameter to the admin URL to flush the user meta cache.
* e.g., http://your-site.com/wp-admin/admin.php?flushmetacache=1
*
* 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.
<?php
/**
* Change the "Choose a membership level" wording on the Paid Memberships Pro account page.
* 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_pmpro_account_page_gettext_changes( $translated, $text, $domain ) {
global $pmpro_pages;
@ipokkel
ipokkel / my-pmprogroupacct-get-group-parent-id.php
Created May 13, 2025 10:10
Helper function to retrieve the group parent User ID of the latest group account a user subscribed to.
<?php
/**
* Helper function to get the parent ID of a group account for a given user.
*
* 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_pmprogroupacct_get_group_parent_id( $user_id ) {