background image

Content tagged with: hook_user

Eric's picture

Here's a quick snippet on how you can remove the History section from a user's profile using hook_user():

<?php
function MYMODULE_user($type, &$edit, &$account, $category = NULL) {
 
// remove history from user profile view
 
if ($type == 'view') {
    unset(
$account->content['summary']);
  }
}
?>

Eric's picture

I am working on an invitation system using organic groups and I needed the ability to programatically add a user to a (closed) organic group when they register for a new account. I tried to use the og_subscribe_user function, but it tests if the group allows registrations. In my situation the groups are closed, so I had to resort to the og_save_subscription function:

<?php
function MYMODULE_user($op, &$edit, &$account, $category = NULL) {
  switch (
$op) {
    case
'insert':

     
// in my example, I'm querying a database for this number:
     
$groupID = 'some number';

     
og_save_subscription($groupID, $account->uid, array('is_active' => 1));
      break;
  }
}
?>