Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?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,
- ]);
- }
- }
Add Comment
Please, Sign In to add comment