Custom Social Feeds In Ultimate Member Plug-In
So, I have a group of people that are registered on a website and it’s important that visitors can see the user profiles in a nice format and MOST importantly, something that is editable by the user (with some validations) to make it easier for both the user and web admin. In this specific case, the users that have a profile have a Twitch account and since Tik-Tok is poppin a little bit, I thought I would include that as well.
It would seem I’m not the only one. I thought by upgrading, maybe they would add more social icons in the header, but alas… same things come up after upgrading. Luckily, the documentation comes in handy in this case (and reminds me of all the old skool Linux guys always telling me to ‘RTFM’ or ‘man’ :\… Yes, I always left reading for last.
So, in this case, it was a pretty simple solution. Although the document says to edit the functions.php file, I would suggest creating a child theme and updating that one. This script will add Pinterest, TikTok and Twitch, but I think it can be altered to add whatever you want if you follow the syntax.
The document reads: “You can use custom PHP code to add more social fields. See the example below. Just modify this code snippet and add it to the file functions.php in the active theme directory.”
With the following code snippet:
<?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['tiktok'] = array(
'title' => __( 'TikTok', 'ultimate-member' ),
'metakey' => 'tiktok',
'type' => 'url',
'label' => __( 'TikTok', 'ultimate-member' ),
'required' => 0,
'public' => 1,
'editable' => 1,
'url_target' => '_blank',
'url_rel' => 'nofollow',
'icon' => 'um-icon-ios-musical-note',
'validate' => 'tiktok_url',
'url_text' => 'TikTok',
'advanced' => 'social',
'color' => '#000000',
'match' => 'https://www.tiktok.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['tiktok_url'] = __('TikTok','ultimate-member');
$array['twitch_url'] = __('Twitch URL','ultimate-member');
return $array;
} );
Have fun!
https://docs.ultimatemember.com/article/1776-ustom-social-fields