|
@@ -175,6 +175,23 @@ function materio_user_block_view($delta = '') {
|
|
|
return $block;
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * Implements hook_module_implements_alter().
|
|
|
+ */
|
|
|
+function materio_user_module_implements_alter(&$implementations, $hook){
|
|
|
+ if ($hook == 'form_alter') {
|
|
|
+ // It is to ensure that hook_form_alter of this module is called
|
|
|
+ // after all other hooks
|
|
|
+ $group = $implementations['materio_user'];
|
|
|
+ if (isset($group)) {
|
|
|
+ unset($implementations['materio_user']);
|
|
|
+ // Then add it back, so it will be at the end of hook array
|
|
|
+ $implementations['materio_user'] = $group;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* Implements hook_form_alter().
|
|
|
*/
|
|
@@ -218,11 +235,19 @@ function materio_user_form_alter(&$form, &$form_state, $form_id) {
|
|
|
materio_user_uc_cart_checkout_form_alter($form, $form_state, $form_id);
|
|
|
}
|
|
|
|
|
|
- // if( $form_id == "user_profile_form" ){
|
|
|
- // //dsm($form, '$form');
|
|
|
- // $form['account']['pass']['#type'] = "new_password_confirm";
|
|
|
- // }
|
|
|
+ // remove newsletters category if user doesn't have access to them
|
|
|
+ if( $form_id == "user_profile_form" ){
|
|
|
+ // dsm($form, '$form');
|
|
|
+ $options = array();
|
|
|
+ foreach ($form['subscriptions']['newsletters']['#options'] as $tid => $name) {
|
|
|
+ if(user_access("subscribe to simplenews category $tid")){
|
|
|
+ $options[$tid] = $name;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $form['subscriptions']['newsletters']['#options'] = $options;
|
|
|
+ }
|
|
|
|
|
|
+ // remove newsletters category if user doesn't have access to them
|
|
|
if ( $form_id == "simplenews_subscriptions_multi_block_form"){
|
|
|
// dsm($form);
|
|
|
$options = array();
|