Здравствуйте уважаемые!
Как переделать код:
// Convert user input social URLs to username values
$facebookUrl = $user->facebook;
preg_match("/https?:\/\/(www\.)?facebook\.com\/([^\/]*)/", $facebookUrl, $matches);
if ($matches){
$user->facebook = $matches[2];
}
$twitterUrl = $user->twitter;
preg_match("/https?:\/\/(www\.)?twitter\.com\/(#!\/)?@?([^\/]*)/", $twitterUrl, $matches);
if ($matches){
$user->twitter = $matches[3];
}
$linkedinUrl = $user->linkedin;
preg_match("/https?:\/\/(www\.)?linkedin\.com\/in\/([^\/]*)/", $linkedinUrl, $matches);
if ($matches){
$user->linkedin = $matches[2];
}
$googleplusUrl = $user->googleplus;
preg_match("/https?:\/\/plus\.google\.com\/([^\/]*)/", $googleplusUrl, $matches);
if ($matches){
$user->googleplus = $matches[1];
}
$pinterestUrl = $user->pinterest;
preg_match("/https?:\/\/(www\.)?pinterest\.com\/([^\/]*)/", $pinterestUrl, $matches);
if ($matches){
$user->pinterest = $matches[2];
}
и добавить
https://vk.com/username и
https://vk.com/id1
https://instagram.com/username
Код оставляет только username или id