Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I Render a Drupal User Profile using api calls?

I'm doing this to render a node and returning the output to an AJAX call and displaying a node inline on a page:

$node = node_load($nid);
$node_view = node_view($node);
echo drupal_render($node_view);

I need to be able to do the same things for a user profile...is it similar?

like image 729
SomethingOn Avatar asked Feb 03 '26 13:02

SomethingOn


1 Answers

It's pretty similar, you can use the following functions:

$account = user_load($uid);
$account_view = user_view($account);
echo drupal_render($account_view);

EDIT

I changed the variable name to use $account instead of $user, just to eliminate the possibility of overwriting the global $user variable.

like image 143
Clive Avatar answered Feb 12 '26 18:02

Clive



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!