Skip to content

WordPressUtilities/wpuusermetas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

User Metas

Adds extra fields to the user administration.

How to install :

  • Put this folder to your wp-content/plugins/ folder.
  • Activate the plugin in "Plugins" admin section.

How to add sections :

Put the code below in your theme's functions.php file. Add new sections to your convenance.

add_filter( 'wpu_usermetas_sections', 'set_wpu_usermetas_sections', 10, 3 );
function set_wpu_usermetas_sections( $sections ) {
    $sections['test-section'] = array(
        'name' => 'Test Section',
        'capability' => 'edit_pages'
    );
    return $sections;
}

How to add fields :

Put the code below in your theme's functions.php file. Add new fields to your convenance.

add_filter( 'wpu_usermetas_fields', 'set_wpu_usermetas_fields', 10, 3 );
function set_wpu_usermetas_fields( $fields ) {
    $fields['wpu_user_height'] = array(
        'name' => 'User height',
        'section' => 'test-section'
    );
    return $fields;
}

Fields parameters :

  • "section" : String (required) / Set this field in a particular section.
  • "name" : String (optional) / Adds a label to the field administration. Default to ID value.
  • "type" : String (optional) / Set a kind of form field. Default to "text".
  • "datas" : Array (optional) / Set datas for a select field. Default to array(0,1)

Fields types :

  • "text" : input type text.
  • "textarea" : textarea field.
  • "editor" : the WYSIWYG editor used in the content of a post.
  • "select" : select between values