Home / Archive / MemberPress: Add Currency Codes To MemberPress
Duplicate Snippet

Embed Snippet on Your Site

MemberPress: Add Currency Codes To MemberPress

This code snippet will add a custom currency to the MemberPress list of available currency codes.

The sample code will add the Egyptian Pound (EGP) to the currency list.

To add a different currency, replace EGP with the three-letter currency code of the needed currency, on this line:

array_push( $codes, 'EGP' );

In addition, to add multiple currencies, add all three-letter currency codes of the needed currencies, separating them with a comma. For example, to add both the Egyptian Pound (EGP) and the Indian Rupee (INR), the above-mentioned line of code would look like this:

array_push( $codes, 'EGP', 'INR' )

Code Preview
php
<?php
function mepr_currency_codes( $codes ) {
    array_push( $codes, 'EGP' ); // Adds 'EGP' to the list of currency codes. To add a different currency, replace EGP with the three-letter currency code of the needed currency.
    return $codes; // Return the modified list of currency codes.
}
add_filter( 'mepr-currency-codes', 'mepr_currency_codes' );

Comments

Add a Comment