Last active
July 7, 2020 11:22
-
-
Save denisbaranov/454914a5f946eb1049748192192575c1 to your computer and use it in GitHub Desktop.
How to show default field value on "view" mode if field value is empty.
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 | |
/** | |
* This code shows default field value on "view" mode if field value is empty in the Profile form of the Ultimate Member. | |
* | |
* You can add this code to the end of the file functions.php in the active theme (child theme) directory. | |
* | |
* Ultimate Member documentation: https://docs.ultimatemember.com/ | |
* Ultimate Member support (for customers): https://ultimatemember.com/support/ticket/ | |
*/ | |
/** | |
* Show default field value on "view" mode if field value is empty. | |
* @param mixed $value | |
* @param string $default | |
* @param string $key | |
* @param string $type | |
* @param array $data | |
* @return mixed | |
*/ | |
function um_show_field_value_if_empty( $value, $default, $key = '', $type = '', $data = array() ) { | |
if( empty( $value ) && $default ) { | |
$value = $default; | |
} | |
return $value; | |
} | |
add_filter( 'um_field_value', 'um_show_field_value_if_empty', 20, 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment