Skip to content

Instantly share code, notes, and snippets.

@yuriinalivaiko
Last active July 7, 2023 13:18
Show Gist options
  • Save yuriinalivaiko/abbba3ab089271a4df6806f27e87a316 to your computer and use it in GitHub Desktop.
Save yuriinalivaiko/abbba3ab089271a4df6806f27e87a316 to your computer and use it in GitHub Desktop.
This code snippet adds a few custom social fields. You can use this example to add more custom social fields.
<?php
/**
* Add more social fields.
* Add this code to the file functions.php in the active theme directory.
*/
add_filter( 'um_predefined_fields_hook', function( $predefined_fields ) {
$predefined_fields['pinterest'] = array(
'title' => __( 'Pinterest', 'ultimate-member' ),
'metakey' => 'pinterest',
'type' => 'url',
'label' => __( 'Pinterest', 'ultimate-member' ),
'required' => 0,
'public' => 1,
'editable' => 1,
'url_target' => '_blank',
'url_rel' => 'nofollow',
'icon' => 'um-icon-social-pinterest',
'validate' => 'pinterest_url',
'url_text' => 'Pinterest',
'advanced' => 'social',
'color' => '#e60023',
'match' => 'https://www.pinterest.com/',
);
$predefined_fields['twitch'] = array(
'title' => __( 'Twitch', 'ultimate-member' ),
'metakey' => 'twitch',
'type' => 'url',
'label' => __( 'Twitch', 'ultimate-member' ),
'required' => 0,
'public' => 1,
'editable' => 1,
'url_target' => '_blank',
'url_rel' => 'nofollow',
'icon' => 'um-icon-social-twitch',
'validate' => 'twitch_url',
'url_text' => 'Twitch',
'advanced' => 'social',
'color' => '#6441a5',
'match' => 'https://www.twitch.tv/',
);
return $predefined_fields;
} );
add_filter( 'um_admin_field_validation_hook', function( $array ) {
$array['pinterest_url'] = __('Pinterest URL','ultimate-member');
$array['twitch_url'] = __('Twitch URL','ultimate-member');
return $array;
} );
@yuriinalivaiko
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment