Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasplevy/f69b91091858b2bf01e2ca901a854a08 to your computer and use it in GitHub Desktop.
Save thomasplevy/f69b91091858b2bf01e2ca901a854a08 to your computer and use it in GitHub Desktop.
<?php // don't copy this line into your functions.php file!
/**
* Override the default value of a custom field retrieved from the usermeta table
*
* note that this filter isn't necessary but *can* be used if you don't simply
* want to retrieve the value of the field from the usermeta table
*
* @param mixed $value value from the usermeta table
* @param obj $user Instance of WP_User for whom data is being retrieved
* @param string $field_id id / name of the field
* @return mixed
*/
function my_custom_field_value( $value, $user, $field_id ) {
// do something with the field value, for example replace underscores with spaces because why not?
$value = str_replace( '_', ' ', $value );
return $value;
}
add_filter( 'lifterlms_get_user_custom_field_value_my_custom_field_id', 'my_custom_field_value', 10, 3 ); // "my_custom_field_id" should be replaced with your field's id!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment