Changing $user_id retrieval and hook

following Pippin's suggestions