Registering Currency Codes

Note: This is part of the developer docs and is considered custom code.
Unfortunately, we cannot provide support for custom code at this time as we do not have the additional resources that would be necessary to provide support for custom code.

If you need assistance with this, please reach out to our list of consultants for further assistance:

By default, Restrict Content Pro supports most major currencies. If your currency is not supported, however, it can be registered through a small PHP code snippet.

Use the rcp_currencies filter to add the new currency:

function pw_rcp_custom_currency( $currencies ) {
	$currencies['MRO'] = 'Ouguiya (UM)';
	return $currencies;
add_filter( 'rcp_currencies', 'pw_rcp_custom_currency' );

This adds the currency to the dropdown in Restrict > Settings > Payments. This is the only necessary step to get your currency operational.

The second, optional step is to add the currency symbol before or after the price. If you skip this step, then the currency code is appended/prepended by default.

Adding the currency symbol is done with either the rcp_{currency code}_currency_filter_before filter (to show the symbol before the price), or the rcp_{currency code}_currency_filter_after filter (to show the currency symbol after). Which filter is used depends on your "Currency Position" settings in Restrict > Settings > Payments.

Here's an example for adding the currency symbol after the price:

function ag_rcp_mro_currency_filter_after( $formatted_price, $currency_code, $price ) {
    return $price . ' ' . 'UM';

add_filter( 'rcp_mro_currency_filter_after', 'ag_rcp_mro_currency_filter_after', 10, 3 );

This would display the price as 10 UM. In the filter name (rcp_mro_currency_filter_after), you need to replace mro with your own currency code that you added in the first step (but all lowercase).

Place these code snippets into a custom plugin. If you're unsure of how to create a plugin, you can use Pluginception to easily create one.

Please note: All of these examples serve as a guideline and are here for your convenience. We do not provide support for troubleshooting or modifying these and we do not provide support for any custom development. If you need help with any of these examples, consider hiring a developer.

Have more questions? Submit a request
Powered by Zendesk