Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save backstageel/48aaecf80213c45964e7a1c106abee63 to your computer and use it in GitHub Desktop.
Save backstageel/48aaecf80213c45964e7a1c106abee63 to your computer and use it in GitHub Desktop.
<?php
/**
* Reorder Social Accounts
*/
private function up1024_reorderSocialAccountOptions($accounts) {
$socialAccounts = civicrm_api3('OptionValue', 'get', [
'option_group_id' => 'website_type',
'name' => ['IN' => $accounts],
]);
$socialAccounts = $socialAccounts['values'];
foreach ($socialAccounts as $optionValueId => $optionValue) {
switch ($optionValue['name']) {
case 'LinkedIn':
$newWeight = 1;
$isDefault = 1;
break;
case 'Twitter':
$newWeight = 2;
$isDefault = 0;
break;
case 'Facebook':
$newWeight = 3;
$isDefault = 0;
break;
}
civicrm_api3('OptionValue', 'create', [
'id' => $optionValueId,
'weight' => $newWeight,
'is_default' => $isDefault,
]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment