How to get the user ID from the last profile page? So, I have a user's profile page where there is a Message button. When I click the message button it should redirect me to a custom page with a form in it. How can I get the user ID from the profile page I visited in order to know where to send the message?
The easiest way would be to add the user id as a ref argument to the form url in your message button, on the user profile page:

&lt;a href="/path/to/custom/form?userid=&lt;?php print arg(1); ?&gt;"&gt;go to custom form&lt;/a&gt;


Then, on your custom form:

$args = drupal_get_query_parameters();
$userid = (isset($args['userid']) ? $args['userid'] : false);