public function UserManager::setProfilePicture in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::setProfilePicture()
- 8 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::setProfilePicture()
- 8.2 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::setProfilePicture()
- 8.3 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::setProfilePicture()
- 8.4 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::setProfilePicture()
- 8.5 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::setProfilePicture()
- 8.6 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::setProfilePicture()
- 8.7 modules/custom/social_auth_extra/src/UserManager.php \Drupal\social_auth_extra\UserManager::setProfilePicture()
Download and set the picture to profile.
Parameters
string $url: Absolute URL of a picture.
string $account_id: Identifier of account on social network.
Return value
bool Returns TRUE if the picture was saved successfully, FALSE if it didn't.
Overrides UserManagerInterface::setProfilePicture
File
- modules/
custom/ social_auth_extra/ src/ UserManager.php, line 112
Class
- UserManager
- Class UserManager.
Namespace
Drupal\social_auth_extraCode
public function setProfilePicture($url, $account_id) {
if ($this->profile && ($file = $this
->downloadProfilePicture($url, $account_id))) {
!$this->account ?: $file
->setOwner($this->account);
$file
->save();
$field_name = $this->fieldPicture
->getName();
$this->profile
->get($field_name)
->setValue($file
->id());
return TRUE;
}
return FALSE;
}