On my user profile page, how do i add some extra html code or custom php code to the user profile page? as i would like to add a custom generated image based on userid in the profile page.

Please advice.


you can also add a block to the "content area" to be shown below the user profile (restricted to user/* pages). In the block you an use short PHP snippets.

| improve this answer | |
  • How are you adding php snippets to a block? Also, are there any security risks as a result of enabling PHP on a live site? – Ashlar Jan 21 '12 at 16:18
  • 1
    just select "PHP code" as the text format. I wouldn't recommend it on large sites, it's more of a convenient way of getting little things done without having to write module code. It can be more risky if it's not configured correctly. If you restrict it to the admin you should be fine: drupal.org/documentation/modules/filter – uwe Jan 21 '12 at 17:22

You can add custom php/html code at user-profile.tpl.php.This file can be found inside the modules/user folder.

| improve this answer | |
  • 1
    Please don't hack core. :-) Add your own theme intead. – paul-m Jan 20 '12 at 20:01
  • @paul-m Sorry, my bad. – aerozeppelin Jan 20 '12 at 23:05
  • thanks a bunch too, if i can't figure out the blocks, i'll try hacking the theme, hehe. :) – vaeros Jan 22 '12 at 7:54
  • 1
    In that case, copy user-profile.tpl.php from modules/user to your theme folder and then edit user-profile.tpl.php there. So you are not hacking the core anymore. – aerozeppelin Jan 23 '12 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.