Last active
December 28, 2015 08:39
-
-
Save larsmaxwell/7473152 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 | |
function apci_groups_favorite_settings_form(&$form_state) { | |
$default_option = FALSE; | |
$form['options'] = array( | |
'#title' => t('Favorite'), | |
'#type' => 'checkbox', | |
'#default_value' => $default_option, | |
); | |
$form['submit'] = array( | |
'#type' => 'submit', | |
'#value' => t('Save'), | |
); | |
return $form; | |
} | |
function apci_groups_favorite_settings_form_submit($form, &$form_state) { | |
global $user; | |
// Get our current group. | |
$group = og_get_group_context()->nid; | |
if (is_array($user->top_groups)) { | |
$group_nids = $user->top_groups; | |
} | |
else { | |
$group_nids = array(); | |
} | |
if ($form_state['values']['options']) { | |
$group_nids[$group] = $group; | |
} | |
else { | |
unset($group_nids[$group]); | |
} | |
drupal_set_message(t('Your form has been saved.')); | |
user_save($user, array('top_groups' => $group_nids)); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment