public function SimpleFbConnectUserManager::setProfilePic in Simple FB Connect 8.2
Same name and namespace in other branches
- 8.3 src/SimpleFbConnectUserManager.php \Drupal\simple_fb_connect\SimpleFbConnectUserManager::setProfilePic()
Downloads and sets user profile picture.
Parameters
User $drupal_user: User object to update the profile picture for.
string $picture_url: Absolute URL where the picture will be downloaded from.
string $fbid: User's Facebook ID.
Return value
bool True if picture was successfully set. False otherwise.
File
- src/
SimpleFbConnectUserManager.php, line 341 - Contains \Drupal\simple_fb_connect\SimpleFbConnectUserManager.
Class
- SimpleFbConnectUserManager
- Contains all logic that is related to Drupal user management.
Namespace
Drupal\simple_fb_connectCode
public function setProfilePic(User $drupal_user, $picture_url, $fbid) {
// Try to download the profile picture and add it to user fields.
if ($this
->userPictureEnabled()) {
if ($file = $this
->downloadProfilePic($picture_url, $fbid)) {
$drupal_user
->set('user_picture', $file
->id());
$drupal_user
->save();
return TRUE;
}
}
return FALSE;
}