2

I know this is simple but can't find the answer. I'm just wanting to put the contents of user-profile.tpl.php in a block. No extra formatting or anything. Just pull the information and put it in a block. It can either be in my custom module or by creating a block. Thanks for your help!

After trying the initial suggestion, I received this error message:

Fatal error: Unsupported operand types user.module

My user-profile.tpl.php doesn't contain the usual information and I should have mentioned that originally. There's a lot to it but I think the problem is here:

$account = menu_get_object('user');

Since it calls that immediately at the top, it may create a problem. Beyond that, the rest of the user-profile.tpl.php file uses the account variable highlighted above to get a bunch more information.

I'm using the latest version of Drupal which is 7.7 at this time.

1 Answer 1

2

For Drupal 6 you create a custom block and let the content be:

theme('user_profile', $account);

For Drupal 7 you do change the code a bit:

render(user_view($account));

In both cases $account if the fully loaded user object who's profile you want to display in the block.

2
  • Thanks @googletorp, that definitely answers the question in most cases. Unfortunately, I'm seeing an error message: Fatal error: Unsupported operand types in /home/XXXX/public_html/modules/user/user.module on line 2534
    – Brandon
    Aug 8, 2011 at 19:03
  • @Bradon: Update your question with more info. What version are you using, what does your code look like.
    – googletorp
    Aug 8, 2011 at 19:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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