The social profiles field type ships with 9 default networks. Themes and plugins can register additional networks through a single filter.
The filter
add_filter( 'membermode_social_networks', function ( array $networks ): array {
$networks['mastodon'] = [
'label' => 'Mastodon',
'icon' => '<svg viewBox="0 0 24 24" fill="currentColor">…</svg>',
'url_pattern' => 'https://mastodon.social/@{handle}',
'placeholder' => 'username',
'handle_type' => 'handle', // or 'url' for free-form links
'handle_pattern' => '/^[a-zA-Z0-9_]{1,30}$/',
];
return $networks;
} );
Field reference
label— Display name shown in the editor dropdown and as the icon’saria-label.icon— Inline SVG. Usefill="currentColor"so the icon inherits the theme’s text color.url_pattern— URL template with{handle}placeholder. Used to build the link from the stored handle.placeholder— Editor input placeholder text.handle_type—handlefor usernames,urlfor free-form links (the input then accepts a full URL and theurl_patternis ignored).handle_pattern— Server-side validation regex. Reject obviously-invalid handles before save.
After registering
The new network appears as a toggle in MemberMode → Fields → Social profiles. If a site has never opened that page (so the per-network setting hasn’t been saved yet), the network is enabled automatically alongside the defaults. On a site where the admin has previously saved per-network toggles, the new network appears disabled — the admin must flip it on.
If you want it forced on for everyone (e.g. you ship it as a paid addon and the customer expects it active), set the option directly during plugin activation:
register_activation_hook( __FILE__, function () {
$current = (array) get_option( 'membermode_social_profiles_enabled_networks', [] );
if ( $current && ! in_array( 'mastodon', $current, true ) ) {
$current[] = 'mastodon';
update_option( 'membermode_social_profiles_enabled_networks', $current );
}
} );
Storage model
All entries live under one user field, social_profiles, as a JSON-encoded array of {network, handle} objects. To read them in PHP:
$repo = MemberModeCorePlugin::instance()->get( 'fields.repository' );
$entries = $repo->get( $user_id, 'social_profiles' );
foreach ( (array) $entries as $row ) {
$url = MemberModeFieldsSocialSocialNetworkRegistry::url_for(
$row['network'],
$row['handle']
);
}