This article contains PHP code and is intended for developers. We offer this code as a courtesy, but don't provide support for code customizations or 3rd party development.
This hook can be used to adjust the attributes of the available currencies in a form.
Usage
add_filter( 'frm_currencies', 'my_custom_function' );
Parameters
- $currencies (array)
Examples
Place the euro symbol on the left side of the number
This example will place the euro symbol on the left side of the number.
add_filter( 'frm_currencies', 'my_custom_function' );
function my_custom_function( $currencies ) {
$currencies['EUR']['symbol_left'] = $currencies['EUR']['symbol_right'];
$currencies['EUR']['symbol_right'] = '';
return $currencies;
}
Replace EUR with the code of the currency you want to filter.
Remove symbol padding from currency
add_filter( 'frm_currencies', 'remove_euro_symbol_padding' );
function remove_euro_symbol_padding( $currencies ) {
$currencies['EUR']['symbol_padding'] = '';
return $currencies;
}
Add a custom currency
Use this code example if you need to add a currency that is not included in the available options.
add_filter('frm_currencies', 'add_custom_currency');
function add_custom_currency( $currencies ) {
$currencies['KRW'] = array(
'name' => __('South Korean Won'),
'symbol_left' => '₩', 'symbol_right' => '',
'symbol_padding' => ' ',
'thousand_separator' => ',',
'decimal_separator' => '', 'decimals' => 0,
);
return $currencies;
}
- Replace KRW with the code of the currency you want to use
- Replace South Korean Won with the name of your currency
- Replace ₩ with the symbol of the currency, which will depend if you want to add it to the left or right.
- Set the thousand separator, decimal separator, and number of decimals, or add a symbol padding in lines 6-8.