1. Home
  2. Docs
  3. WordPress Studio Framework
  4. Framework Locations
  5. User Profile Options

User Profile Options

The WordPress Studio Framework (WPSF) can also be used to extend the User Profiles in WordPress.

Arguments for User Profiles

NameTypeDefaultDescription
data_typestringserializeDatabase save option type (serialize or unserialize)
defaultsarray Sets all default values from an external array (optional)
classstring Extra CSS classes (space separated) to apend to the main framework.

Example User Profile Framework

// Check to see if WPSF is loaded
if ( class_exists( 'WPSF' ) ){

  //Unique slug
  $prefix = 'profile_options';

  //Create profile options
  WPSF::createProfileOptions( $prefix, array(
    'data_type' => 'serialize',
  ));

  //Create section
  WPSF::createSection( $prefix, array(
    'fields' => array(
      array(
        'id' => 'example-text',
        'type' => 'text',
        'title' => 'Example Text',
      ),
      array(
        'id' => 'example-textarea',
        'type' => 'textarea',
        'title' => 'Example Textarea',
      ),
    )
  ));
}

Extract Option Value (data_type => serialize)

$user_id = get_current_user_id();
$user_meta = get_user_meta( $user_id, 'profile_options', true );

echo $user_meta['example-text'];
echo $user_meta['example-textarea'];

Extract Option Value (data_type => unserialize)

$user_id = get_current_user_id();
echo get_user_meta( $user_id, 'example-text', true );
echo get_user_meta( $user_id, 'example-textarea', true );
Was this article helpful to you? Yes No

How can we help?