Skip Navigation
availability:

WPML Version: 4.1.0

description:

Custom fields can be encoded in a format that WPML does not understand. Those fields have to be decoded and encoded before WPML can translate them. To achieve this, the wpml_decode_custom_field and wpml_encode_custom_field filters must be used. These filters can be used if there is additional custom encoding besides the ones already handled by WPML.

type:
filter
category:
Site-Wide Language Information
parameters:
apply_filters( $custom_field_val, $custom_field_name )
$custom_field_val
Value contained within field that needs to be decoded
$custom_field_name
Name of the field that needs to be decoded
hook example usage:

Example

add_filter( 'wpml_decode_custom_field', 'my_decode_function', 10, 2 );

function my_decode_function( $custom_field_val, $custom_field_name ) {
   if ( $custom_field_name === 'my-special-field' ) {
      $custom_field_val = my_special_decoding_function( $custom_field_val );
   }

  return $custom_field_val;
}