Last active
December 7, 2020 11:21
-
-
Save denisbaranov/5d3904d7765c1f977a1cffd0d9e53756 to your computer and use it in GitHub Desktop.
Empty fields are hidden on profile form "view" mode. It may look weird. You may use the code snippet below to display fallback value "--" for the empty fields. It works only for the "view" mode. Just add this code snippet to the functions.php file in the active theme (child theme) directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Displays fallback value if the field value is empty. For the "view" mode only. | |
* @param string $value | |
* @param string $default | |
* @param string $key | |
* @param string $type | |
* @param array $data | |
* @return string | |
*/ | |
function um_field_value_fallback( $value, $default, $key, $type, $data ) { | |
if ( empty( $value ) && isset( UM()->fields()->viewing ) && UM()->fields()->viewing === true ) { | |
$fields_without_metakey = UM()->builtin()->get_fields_without_metakey(); | |
if ( !in_array( $type, $fields_without_metakey ) ) { | |
$value = '--'; | |
} | |
} | |
return $value; | |
} | |
add_filter( 'um_field_value', 'um_field_value_fallback', 50, 5 ); |
Author
denisbaranov
commented
Mar 29, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment