Created
June 22, 2018 07:37
-
-
Save backstageel/48aaecf80213c45964e7a1c106abee63 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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