How to pass taxonomy reference field data into a views reference contextual filter arguement with PHP code?
As the help text puts it, you just need to return the value. Of course, your actual question might be to access the term id but you have not specified that.

For example, if you want to show the view as a block on a regular node page, and the node contains the tid, you would use code like this:

// Lets assume that this view will always be shown on a node page.
$node = arg(1);
$tid = $node-&gt;field_term_reference[0][LANGUAGE_NONE]['value'];
return $tid;


This code could be improved a lot but it gives the basic idea.

As a side note, if your scenario is as per above, then consider using Panels and pass in the term id using contextual arguments.

Side note 2: Your screenshot shows filter dialog for Term Name whereas your question asks for term ID. I have given the example for the latter. I hope it helps get you started.