Before I display ACF field, I want to manipulate it

Before I display ACF field, I want to manipulate it with my codes how to do this?
Are there any hooks documentation?
I want to manipulate my price field to display converted price on multiligual page. How do I do this?

since you can

  • Improvement: Call function by using dynamic tag {return=your_function('string', get_the_ID())}
    give it a try, I use it to make automatic caption unit conversions in/cm cm/in and it works just as written
1 Like

Can I use the Code Snippets plugin to call my function out on my ACF field.

Do I have to use it in the post edit screen?

The thing is, I have price saved in USD in ACF field, which I want to convert on other Multiligual pages by manipulating the field using hook.

Hi @JuGa could you please post a full exemple i.cluding Cwii ly sttings and code php

1 Like

Hi, thank you for your patience, yesterday was Thanksgiving here, kept me luckily away from my computer.

Regarding manipulating ACF fileds before displaying them, here a little example:

So you have a php function that does all the changes you are looking for such as,
and yes, it can absolutely be added at a snipped through code snippets :

function change_my_field($post_id ) {
// get ACF field value through the $post_id
// do all you have to do with it
//return it
return $my_changed_field;

Then within my page or template, within a text block (either parapraph or heading)
I would just call that function as follow:


and voila!

Do you think that would help with your project?
You still need now to get the the language of the page in order to get the correct currency but as I don’t know how you manage that information, hard to help on that part…



Super @JuGa
I will try and keep you posted.

1 Like

Sorry but I can’t set this function.

Here is what I have done.

An image with the show condition:


An image with the show condition:


The function:

function change_my_field( $user_id ) {
	$my_local_field = true;
	return $my_changed_field;

Normally, at lest one of the image must be displayed: but nothing is displayed!

Can you help me to find where the mistake is.

well the function returns $my_changed_field that isn’t set anywhere
try to return $my_local_field instead or set

Sorry, I made a bad copy of my function.

The function that I tested is:

function change_my_field($user_id ) {
	$my_changed_field = true;
	return $my_changed_field;

and nothing is displayed: neither “return=true” nor “return=false”

Great, it worked on the main language, but since I’m using WPML, it is not working in other languages why?

Just checked, as I never used functions in conditions before,
well, in the conditions, you don’t need to add {return=change_my_field()}
because you chose function return in the first select menu, you just need the name of your function and arguments in the next field
such as change_my_filed()
I just tried and it seems to work

You want to use the {return=my_function()} to evaluate a function within a textfield directly.

Hope that will help.


I never used WPML and I understand you are looking to change the currency, depending of the language of the post, right?
So you need to check the language of the current post and apply your change in currency accordingly.

Here, I found a basic example of such for WPML

So in your php snippet you’ll have something like:

function My_Local_Currency($post_id){
//get the amount you want to convert
//get the language of current post
$post_language_information = apply_filters( ‘wpml_post_language_details’, NULL, $post_id );
$this_post_lang = $post_language_information[“language_code”];
//then apply the changes you want depending of the language
if($this_post_lang == ‘en’){
//do your currency conversion
$conversion_rate=3.2; }
//do your currency conversion
$conversion_rate=0.2; }
//convert the amount
//return the converted value
return $my_converted_amount;

Then you can just call that function in your Cwicly textfield where you need it to display using the technique we discribed earlier.

Hope that helps.

Thank you @JuGa
Works fine!


Super! Glad to help!