When I View Profile I always see History (Member for .. days ..hours). I don't like it and I would like to remove it. But How? Please help me?

Comments

surajsapkota’s picture

Please GIve me suggations on how to remove the History ( lying in the profile).

Please! Please!! please!!! help!!!!

azim’s picture

You would have to check http://drupal.org/node/35728

I wouldn't know any other simpler way. Am trying to edit them myself too.

bwalls’s picture

I went and opened the user.module file in word pad, searched for history, and deleted that whole line of code. That seems to have worked for me.

ceejayoz’s picture

Editing core code is a bad idea. Your changes will get wiped out on an upgrade.

rajmataj’s picture

For Drupal 6, copy this file from your /sites/modules/user directory:
user-profile-category.tpl.php

put the copy into your custom theme directory and within that file, replace this code

<?php if ($title) : ?>
  <h3><?php print $title; ?></h3>
<?php endif; ?>

<dl<?php print $attributes; ?>>
  <?php print $profile_items; ?>
</dl>

with:

<?php if ($title && $title != t(History)) : ?>
  <h3><?php print $title; ?></h3>
<?php endif; ?>

<?php if ($title != t(History)) : ?>
<dl<?php print $attributes; ?>>
  <?php print $profile_items; ?>
</dl>
<?php endif; ?>

reference url: http://network.acquia.com/node/1112624#comment-20421

runacid’s picture

Maybe a bit late, but it does work that way!

Open the user.module file in the Module>>user folder and comment out line 458 to 466 (including the '}')
(tested with Durpal 5.2)

Insane Fisher’s picture

Hi. I am also looking to remove the history from the views in profile. Do I actually have to count the lines?!!? How do I know which lines are are 458 to 466, a how do I comment something out?

Thanks!
Insane Fisher
www.insanefishingclub.com

I am the building. I am the tree. I am God, for God's in me.

runacid’s picture

Just saw your post..
Well I don't know any other way of doing it. Just get some basic code editor which is capable of counting the lines. (I use "proton", which is really nothing fancy)
There are some really powerful tools out there for free as well, for example Eclipse. Instead of deleting the relevant code, you could also just comment it out,

selff’s picture

i am correct 1 line (num 474) in this block code:


/**
 * Implementation of hook_user().
 */
function user_user($type, &$edit, &$user, $category = NULL) {
  if ($type == 'view') {
    $items['history'] = array('title' => t('Member for'),
      'value' => format_interval(time() - $user->created),
      'class' => 'member',
    );

    return array();//t('History') => $items

// ...

instead return array(t('History') => $items);
write this return array();

selff’s picture

this is correct way http://drupal.org/node/35728
(use profile module in core)
1) create in template.php function phptemplate_user_profile

function phptemplate_user_profile($user, $fields = array()) {
return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));
}

2) create file user_profile.tpl.php and output what you want,
test:

<div>
    <h3>$USER:</h3>
    <?php foreach($user as $k=>$v)
        if (is_array($v)) foreach($v as $kk=>$vv) print "--$kk=$vv<br />\n";
        else print "$k=$v<br />\n";
        ?>

    <h3>$FIELDS:</h3>
    <?php foreach($fields as $k=>$v) {
        if (is_array($v)) {
            foreach($v as $kk=>$vv) {
                if (is_array($vv)) foreach($vv as $kkk=>$vvv) print "-- -- $kkk=$vvv<br />\n";
                else print "-- $kk=$vv<br />\n";
            }
        }
        else print "$k=$v<br />\n";
        }
        ?>
</div>
MarcoR’s picture

You should not correct drupal's output by changing drupal's code.
If you want to change functionality instead of appearance, you should choose to modify drupal's output in a custom module. In the example, you would have a module called mywebsite. Into the file mywebsite.module you put the following code:

/**
 * Implementation of hook user to do some customization of this website
 */
function mywebsite_user($type, &$edit, &$user, $category = NULL) {
  if ($type == 'view') {
    // turn off history by returning an empty array having the same key as the one defined in user_user()
    $items['history'] = array();
    return array(t('History') => $items);
  }
}

Put the file into /sites/all/modules/custom/mywebsite directory. Put an according mywebsite.info into the directory, too. Activate the module as usual. More information in module developer guide.

leanazulyoro’s picture

I'm having the same issue, and i tought it would be as easy as you say MarcoR, in theory that should do it, but it doesn't :S, have you tried it? or you just came up with it and suggested it without trying?

BarisW’s picture

Your code can be improved by using the already known $user variable and just empty the arrays you don't want to be outputted. For instance:

function mywebsite_user($type, &$edit, &$user, $category = NULL) {
  if ($type == 'view') {
    // Turn of user history
    $user->content['summary']['member_for'] = array();

    // Turn of userpoints
    $user->content['userpoints'] = array();
  }
}

Baris Wanschers (@BarisW)
Drupal specialist

rgammon’s picture

There appears to be a module that can do this: http://drupal.org/project/myaccount_alter

"Gets rid of unwanted sections on the 'My Account' page such as the 'History' section or anything added there by a contributed module.

"Install, then go to the myaccount_alter settings page and check off the sections you would like to disable."

I haven't used it, but was searching site on similar keywords and thought this might be a good lead for you. I note the module was updated 2008-Feb-16 (rel. 5.x-1.2), which indicates its a living project.

robb0632’s picture

How does that history data get there?

robb0632’s picture

?

VM’s picture

its part of core.

leanazulyoro’s picture

There is a hook_profile_alter to modify this, just implement it in a module:

function mymodule_profile_alter(&$account, &$fields) {  
    foreach ($fields AS $category => $items) {
        if($category == 'History') {
            unset($fields[$category]);
        }
      }  
}
sobi3ch’s picture

If you using other language then default English, don't forget about t() function other wise above code will not work.
I've change 'History' > t('History')

/**
 * implementation of hook_profile_alter
 */
function mymodule_profile_alter(&$account, &$fields) { 
  foreach ($fields AS $category => $items) {
    if($category == t('History')) {
      unset($fields[$category]);
    }
  } 
}
mortenson’s picture

how would be this code for Drupal6?

mechler’s picture

In Drupal6, create a file in your theme's directory called: user-profile.tpl.php

Give that file the following contents:

<div class="profile">
<?php
unset($profile[t('summary')]);
foreach ($profile AS $k => $v) {
  print $v;
}
?>
</div>

That's all I did to remove that section. Hope this helps!

Web Developer, Iowa State University College of Veterinary Medicine

mortenson’s picture

try the code but nothing happened, could you give any detail missing please?

drubeedoo’s picture

Clear your drupal cache under: www.example.com/admin/settings/performance in order for this change to take effect.

ressa’s picture

Adding the user-profile.tpl.php file solved it in 30 seconds, no need for an extra module, thanks!

wendyconnect’s picture

4 years later - and this solution came in very handy - many thanks! We had changed our theme, and the person doing it hadn't realised that there was a user-profile.tpl.php file in the original theme folder that contained this modification. I just copied it into the new theme folder and - hey presto! "History" disappeared - fantastic.

magnestyuk’s picture

...or make a custom module and put this inside:

<?php
function mymodule_profile_alter(&$account) {
  foreach ($account->content AS $key => $field) {
  	if ($key=='summary') {
      unset($account->content['summary']);
    }
  }
}
?>
ellanylea’s picture

Write your own custom module and put this code in it:

/**
* Implementation of hook_profile_alter
*/
function custom_profile_alter(&$account) {
unset($account->content['summary']['#title']);
unset($account->content['summary']['member_for']);
}
Shai’s picture

In the example above from @AdAstra , the custom module's name is "custom." Lets say you named your module, "sitecustomizations." So then the code would look like:

/**
* Implementation of hook_profile_alter
*/
function sitecustomizations_profile_alter(&$account) {
unset($account->content['summary']['#title']);
unset($account->content['summary']['member_for']);
}

In other words; you prepend "_profile_alter" with your module name.

Continuing with this example, you create a directory called: sitecustomizations

You place that directory in sites/all/modules

That directory would contain two files: sitecustomizations.info and sitecustomizations.module

The code snippet above goes in sitecustomizations.module

In sitecustomizations.info you would put:

name = Site Customizations
description = Module for implementing site customizations
core = 6.x

Once you enable the module on the modules admin page, your "History" section will disappear from user profiles.

adam_b’s picture

If you just want to hide the history, it might be easiest just to hide the tab with http://drupal.org/project/tabtamer

davepotts’s picture

This worked like a charm, thanks!

Other noobs (like myself) who are reading this might want to remember to add your php delimiters so your .module file will actually contain:

<?php
/**
* Implementation of hook_profile_alter
*/
function sitecustomizations_profile_alter(&$account) {
unset($account->content['summary']['#title']);
unset($account->content['summary']['member_for']);
}
?>

I ended up with code printed into my header on my first try. :|

Can anyone tell me how to edit this to also get rid of the "view recent blog entries?"

Sagar Ramgade’s picture

Hi,

Here's another way of removing member since using hook_user

<?php
/**
* Implementation of hook_user
*/
function custommodule_user($op, &$edit, &$account, $category = NULL) {
                if ($op == 'view') {
               unset($account->content['summary']);
                }
}
?>

Regards
Sagar

Acquia certified Developer, Back end and Front specialist
Need help? Please use my contact form

tcheard’s picture

Note that you shouldn't actually use the php close tag, unless you are going to reopen the php tags later in the file, as per the drupal coding standards:
http://drupal.org/node/318#phptags

marcelleisp’s picture

I accomplished it by doing this:

1. Move the file user-profile-category.tpl.php from modules/user to your sites theme folder.
2. Edit the file that is now in your theme folder and comment out everything using the <!-- --> html tags.
3. Clear your cache.

If there is a better way for doing this in D7 please let me know.

VM’s picture

in D7 history is a field on the user entity

goto admin/config/people/accounts/display
set the format of the history field to 'hidden'

Shai’s picture

@vm Thank you!

sushilkr’s picture

in D7 history is a field on the user entity

goto admin/config/people/accounts/display set the format of the history field to 'hidden'

VM’s picture

ressa’s picture

If you want to just hide the header ("History"), this will do:

.profile h3 {
  display: none;
}

Of course, make sure that you don't have any other h3's in there.

Anonymous’s picture

its pretty simple Go to Home » Administration » Configuration » People » Account settings » Manage Display , History -> Format chose hidden.

VM’s picture

The above suggestion applies only to Drupal 7.x and was already stated above 2 years ago @ https://drupal.org/comment/5256332#comment-5256332

gumdal’s picture

This is the best way to hide history related information. This helped me.

Raj Pawan G

Karim EL Shazly’s picture

Thanks a lot :)

batigolix’s picture

In Drupal 7 it can also be removed through code using hook_user_view_alter (in a similar fashion as the hook_profile_alter implementations that are explained above).

In a custom module add:

/**
 * Implements hook_user_view_alter().
 */
function YOURCUSTOMMODULE_user_view_alter(&$build) {
  unset($build['summary']);
}

I tried to hide the History section using Features (exporting the User view mode) but that doesnt work.

avinash_thombre’s picture

There is no need to manipulate the Drupal core code or to add anothe code. Just go to following path of your site and set the History field's dispaly setting from "Visible" to "Hidden". That's it!

/admin/config/people/accounts/display

VM’s picture

The advice you've provided wasn't possible in Drupal 5.x Please don't resurrect old posts for EOL versions of Drupal core. Thank you.