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/843e949e44c6248a3040799d73da609b to your computer and use it in GitHub Desktop.
Save thomasplevy/843e949e44c6248a3040799d73da609b to your computer and use it in GitHub Desktop.
<?php // don't copy this line into your functions.php file!
/**
* Add a custom field to the user's profile on the WP admin panel
* @param array $fields associatve array of field data
* @return array
*/
function my_custom_user_fields( $fields ) {
$fields['llms_custom_field_id'] = array( // array key *should* the value you want to store in the WP usermeta table
'description' => 'A short description of this field',
'label' => __( 'My Custom Field Label', 'my-text-domain' ),
'required' => false, // if you want this field to be required, switch to "true"
'type' => 'text', // accepts any valid HTML5 input type, note that we don't have support for textareas or select elements!
);
return $fields;
}
add_filter( 'lifterlms_get_user_custom_fields', 'my_custom_user_fields', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment