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/52e4e5aa3f619e4e3ca8ea2ec4937c62 to your computer and use it in GitHub Desktop.
Save thomasplevy/52e4e5aa3f619e4e3ca8ea2ec4937c62 to your computer and use it in GitHub Desktop.
<?php // don't copy this line into your functions.php file!
/**
* Customize the value stored in the database before the field data is saved
*
* This runs after validation so no need to re-validate here
*
* @param mixed $value user submitted value
* @param obj $user WP_User instance
* @param string $field_id name / id of the field
* @return mixed
*/
function my_custom_field_save( $value, $user, $field_id ) {
// for example ensure remove protocal prefixes from the beginning of a web address field
$value = str_replace( array( 'https://', 'http://' ), '', $value );
return $value;
}
add_filter( 'lifterlms_save_custom_user_field_my_custom_field_id', 'my_custom_field_save', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment