MemberPress: Import Dropdown Options for Custom Fields

function mepr_cust_import_options() { if( isset( $_REQUEST[‘import-options’] ) ) { // For this code snippet to work, a custom dropdown field must be created at Dashboard > MemberPress > Settings > Fields tab. $mepr_options = MeprOptions::fetch( true ); $key = ‘mepr_custom_dropdown’;…Continue reading

MemberPress: Set UK Transactions VAT to 0

function mepr_cust_uk_vat( $vat_countries ) { if( isset( $vat_countries ) ) { $gb = $vat_countries[‘GB’]; if ( isset( $gb ) ) { $gb[‘rate’] = 0; $vat_countries[‘GB’] = $gb; } } return $vat_countries; } add_filter( ‘mepr-vat-countries’, ‘mepr_cust_uk_vat’ );Continue reading

MemberPress: Tax Only UK

function mepr_cust_tax_only_uk( $tax_rate, $country, $state, $postcode, $city, $street, $user, $prd_id ) { if ( $country != ‘GB’ ) { $tax_rate->tax_rate = 0.0; } return $tax_rate; } add_filter( ‘mepr_find_tax_rate’, ‘mepr_cust_tax_only_uk’, 99, 8 );Continue reading

MemberPress: Add Address Fields to Authorize.net

function add_address_to_recurring( $args, $txn, $sub ) { $user = new MeprUser( $txn->user_id ); if ( $user->address_is_set() ) { $addr = $user->full_address( false ); $args[‘subscription’][‘billTo’][‘address’] = $addr[‘mepr-address-one’] . ( isset($addr[‘mepr-address-two’] ) ? ‘ ‘ . $addr[‘mepr-address-two’] : ” ); $args[‘subscription’][‘billTo’][‘city’] =…Continue reading

MemberPress: Changes Product Image on the Checkout Page (copy)

function mepr_custom_checkout_image() { ?> (function($) { $(document).ready(function() { // Select the product image on the checkout page and change its source to a new image URL $(“.mp-table > tbody:nth-child(1) > tr:nth-child(1) > td:nth-child(1) > img:nth-child(1)”).attr(“src”,”https://airfryerkogebogen.dk/wp-content/uploads/2024/11/airfryerkogebogen.png”); }); })(jQuery); <?php } add_action(…Continue reading

MemberPress: Free-Views-Left Counter

function mepr_display_cookie() { if ( isset( $_COOKIE[‘mp3pi141592pw’] ) && ! empty( $_COOKIE[‘mp3pi141592pw’] ) ) { $cookie = $_COOKIE[‘mp3pi141592pw’]; $mepr_options = MeprOptions::fetch(); $num_views = base64_decode( $cookie ); if ( $num_views < $mepr_options->paywall_num_free_views ) { $free_views = $mepr_options->paywall_num_free_views – $num_views; echo ‘You…Continue reading

MemberPress: Redirect To Specific Page Based on Rule

function mepr_redirect_specific_page( $redirect_url, $delim, $uri ) { $current_post = MeprUtils::get_current_post(); $rules = MeprRule::get_rules( $current_post ); if ( !empty( $rules ) ) { $rule_ids = array_column( $rules, ‘ID’ ); if ( in_array( 123, $rule_ids ) ) { $redirect_url = ‘https://yourdomain.com/register/membership-1/’; }…Continue reading