Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By looklively on
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
The location
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.
That did the trick ...
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.
Don't do that!
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.
What about .css ?
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;}
Good
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 :-)
Nice one!
Hey mblazke!
Top hack ...
As JirkaRybka says above, not exactly 'by the book' but it works ...
Thanks, Buddy.
the css method didnt work
the css method didnt work for me in D6
Subscribing. I have the
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?
override theme_user_profile
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:
Now is:
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
Calrity Please
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.
Themable functions
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... ;)
Good to know!
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?
Suggestion
As a possibility, rather than having if ($category != 'History'), keep it stock. Then before the foreach, put unset($fields['History']);
I18n version
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:
Thanks!
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
There's a module that does
There's a module that does just this: http://drupal.org/project/myaccount_alter
drupal 6 solution
To remove the "member for"
I did this in mymodule.module
That seamed to work for me!
Drupal 7 template.php solution
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.
You find it here:
You find it here: admin/config/people/accounts/display
Good one man, working fine :)
Good one man, working fine :)