The WordPress Studio Framework (WPSF) can also be used to extend the User Profiles in WordPress.
Arguments for User Profiles
Name | Type | Default | Description |
---|---|---|---|
data_type | string | serialize | Database save option type (serialize or unserialize) |
defaults | array | Sets all default values from an external array (optional) | |
class | string | 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 );