Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save champsupertramp/b07f53c98c6f65a63ef20fc583aaccd6 to your computer and use it in GitHub Desktop.
Save champsupertramp/b07f53c98c6f65a63ef20fc583aaccd6 to your computer and use it in GitHub Desktop.
Ultimate Member - Enable username input in Social Profile URLs Field
<?php
/**
* @note - Ensure that the Social Profile URLs validation is set to "Alpha-Numeric Value" instead of "Facebook URL" etc.
*/
add_filter( 'um_profile_field_filter_hook__', 'um_custom_social_profile_links', 88, 3 );
function um_custom_social_profile_links( $value, $data, $type ){
if ( ! $value ) {
return '';
}
if( 'url' == $type && isset( $data['metakey'] ) ){
if( in_array( $data['metakey'], ['facebook','twitter','instagram'] ) ){
switch ($data['metakey']) {
case 'facebook':
return "<a target='".$data['url_target']."' href='"."https://www.facebook.com/".str_replace("http://","",$value)."'>https://www.facebook.com/".str_replace("http://","",$value)."</a>";
break;
case 'twitter':
return "<a target='".$data['url_target']."' href='"."https://www.twitter.com/".str_replace("http://","",$value)."'>https://www.twitter.com/".str_replace("http://","",$value)."</a>";
break;
case 'instagram':
return "<a target='".$data['url_target']."' href='"."https://www.instagram.com/".str_replace("http://","",$value)."'>https://www.instagram.com/".str_replace("http://","",$value)."</a>";
break;
}
}
}
if ( is_array( $value ) ) {
$value = implode( ', ', $value );
}
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment