Hi,

I want to remove the "member for" snippet from the user profile page.

Customising the user profile layout as recommended here http://drupal.org/node/35728
seems fine, but I want to leave the user profile as it is minus the "member for" snippet.
So from where would I copy the user profile layout that I have already?
Then I could create a template.php and a user_profile.tpl.php file, copy this in and just remove the "member for" bit.

Thanks.

Comments

JirkaRybka’s picture

I don't know much about copying and theming and so forth, but I once changed something about this item on user-profiles (just patching the original file for different wording - unclean but simple solution for me). It's located in the User module, i.e. modules/user/user.module.

looklively’s picture

Thanks, JirkaRybka .

It's a bit of a corner-cut that I was hoping to avoid.
But ... job done.

-------------------------
For anyone else ... I removed
{
$items['history'] = array('title' => t('Member for'),
'value' => format_interval(time() - $user->created),
'class' => 'member',
);

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

from approx line 450 of modules/user/user.module

------------------------

Cheers.

looklively’s picture

Please ignore the above.
Doing this has knock-on effects, it removes editing options in the user profile.

Ho hum, back to the drawing board.

Can anyone help me here?

The site I am building is for an established organisation and including "member for" (ie member of the website for) would seem to indicate length of membership of the organisation.
This is then misleading.

Thanks.

mblazke’s picture

I've simply added the following to my theme/style.css
div.profile dl dt.user-member, div.profile dl dd.user-member { display: none;}

JirkaRybka’s picture

Good idea, although I think CSS is not recommended for this kind of use (CSS is for presentation, not content-handling). Still it should work, probably the easiest hack :-)

looklively’s picture

Hey mblazke!
Top hack ...
As JirkaRybka says above, not exactly 'by the book' but it works ...

Thanks, Buddy.

mortenson’s picture

the css method didnt work for me in D6

joachim’s picture

Subscribing.
I have the exact same requirements -- new website for an old organization, and indicating how long it is since a member signed up to the site is misleading.
I wonder if there's enough demand to request this be made an option in the user profile module?

seanberto’s picture

There's a themable function in the user.module with the name theme_user_profile. Copy that into your template.php and change "theme" to "phptemplate" or the name of your custom theme. Then, you can remove the entire history section with a simple if statement:

was:


  foreach ($fields as $category => $items) {
      if (strlen($category) > 0) {
        $output .= '<h2 class="title">'. check_plain($category) .'</h2>';
      }
      $output .= '<dl>';
      foreach ($items as $item) {
        if (isset($item['title'])) {
          $output .= '<dt class="'. $item['class'] .'">'. $item['title'] .'</dt>';
        }
        $output .= '<dd class="'. $item['class'] .'">'. $item['value'] .'</dd>';
      }
      $output .= '</dl>';
  }

Now is:


  foreach ($fields as $category => $items) {
    if ($category != 'History') {
      if (strlen($category) > 0) {
        $output .= '<h2 class="title">'. check_plain($category) .'</h2>';
      }
      $output .= '<dl>';
      foreach ($items as $item) {
        if (isset($item['title'])) {
          $output .= '<dt class="'. $item['class'] .'">'. $item['title'] .'</dt>';
        }
        $output .= '<dd class="'. $item['class'] .'">'. $item['value'] .'</dd>';
      }
      $output .= '</dl>';
    }
  }

I think that this is a better approach then altering core module code, or just using css (as display: none will hurt your search engine rankings).

Sean Larkin

Insane Fisher’s picture

Can you give a little clarity to these instructions? I am very new to Drupal and to editing code. There seems to be something missing from the instructions, but I can not place a finger on what.

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

JirkaRybka’s picture

Themable functions (for Drupal 5 at least) are like this:

- Copy/paste the (themable!) function from a module into your theme - to the file template.php (if your theme haven't one yet, create a new empty file with <?php line at the top).

- Change the name of the function (at the function foo(...) { line) appropriately. Do all edits on the copy of the function, located in your theme! (NOT the original in the module)

- Now the function in your theme is used by Drupal, instead of the original, so you can change it as You like, without really changing the Drupal core files. This is supposed to make things clean, appearance changes fixed inside the theme rather than modules, and save you problems if updating core to a newer version.

- But still, you should check whether the copied function is up-to-date with the new Drupal version if upgrading (so in my opinion, it's not as much of a win, as it might look like)

- Although this code-editing and copy/pasting thing is difficult and dangerous for a newbie, it's the Drupal way of doing things, so you're likely to receive this kind of advice nearly every time you ask... ;)

kriskd’s picture

Thanks for this bit of code.

Question -- what else come be customized while still using the foreach loop? For example, this snippet show how to change the word "history" to "member for", but you have to explicitly call that bit of code. What if I want to generate everything with the foreach loop, but tweak a few things like that? Can that be done and if so, how?

steve.colson’s picture

As a possibility, rather than having if ($category != 'History'), keep it stock. Then before the foreach, put unset($fields['History']);

mapiedra’s picture

I have been working on the customization of a Drupal installation for some users (each user will have his/her own Drupal file set and database). There was a problem, though, because the interface is displayed in Spanish by default (the user could set it up in English, German or other language).

The "History" section is still displayed when the "if" statement does not sort it out. This scenario occurs when the language of the "History" string does not match with the language of the interface (i.e. you look for "History" and it reads "Historial").

Even when a PHP "or" (||) statement could be defined for the most probable languages, there is a more elegant solution. It is possible to use the t() function (string translation) from the API instead of the hard-coded "History" string. For instance:

 foreach ($fields as $category => $items) {
    if ($category != t('History')) {
      if (strlen($category) > 0) {
        $output .= '<h2 class="title">'. check_plain($category) .'</h2>';
      }
      $output .= '<dl>';
      foreach ($items as $item) {
        if (isset($item['title'])) {
          $output .= '<dt class="'. $item['class'] .'">'. $item['title'] .'</dt>';
        }
        $output .= '<dd class="'. $item['class'] .'">'. $item['value'] .'</dd>';
      }
      $output .= '</dl>';
    }
  }
Itangalo’s picture

Thanks to mapiedra and the rest who helped me with this theming issue!
I refer to this post in a short guide on how to use theme funktions, written in the Swedish group forum.

//Johan Falk, Sweden

joachim’s picture

There's a module that does just this: http://drupal.org/project/myaccount_alter

firecentaur’s picture

To remove the "member for"

I did this in mymodule.module

function mymodule_profile_alter(&$account){
 if (isset($account->content['summary']) && 
     isset($account->content['summary']['member_for'])){
        $account->content['summary']['member_for']['#title'] = ''; 
        $account->content['summary']['member_for']['#value'] = '';
    }
}

That seamed to work for me!

dannybrowne’s picture

I know this is an old thread but for anyone who gets stuck here is a more elegant solution for any drupal7 installations that overrides the _preprocess_user_profile function.

Add this to your template.php file -replacing 'mytheme' with the name of your theme.

function mytheme_preprocess_user_profile(&$variables) {

	 if (isset($variables['user_profile']['summary']['member_for']['#title'])){
			$variables['user_profile']['summary']['member_for']['#title'] = 'replacement text';
		}
    
}
Develup’s picture

You find it here: admin/config/people/accounts/display

Tharick’s picture

Good one man, working fine :)