menu_get_object() not returning node object when view's display is Entity Reference I needed get field's value and pass it as contextual filter to "entity reference view" just described as views and contextual filters with entity reference field.

But $Node = menu_get_object() is not retuning node object. 

The scenario

Nodes Items of custom content type

Title : Sony LCD
Tags : electronic  

Title : The godfather
Tags :Books
.
.
Items(n)

Node of custom content type Review. It's node id is 10

Title : Make a Review
Filter Tags : Taxonomy terms reference (e.x electronic, books, movies etc)  

Attach a entityform to above node using entity reference and also back referenced with enityreference_current

My Review Item : EnityReference field - Entity reference view - Autocomplete widget
Review : text area 

When node/10 is viewed, user will have to fill "my review item",but should be filter based on "Filter tags" that was already set.

Code inside VIEWS PHP under Contextual Filter

$node = menu_get_object ();
$ Related_ids = array ();
    $ Related = field_get_items ('node', $node, 'field_filter_tags') // Get the term reference field
    if ($related &amp;&amp; is_array ($related) &amp;&amp; sizeof ($related)&gt; 0) {
      for ($i = 0; $i &lt;count ($related); $i++) {
        $ Related_ids [] = $related [$i]['target_id'];
      }
    }
    return implode (',', $related_ids);//to perform AND 


Update : I also tried with $node= node_load(arg(1)); , this time $node variable set but not type of node. Then I dpm(arg(1)); it shows string autocomplete(yes just autocomplete not string entered in field).
The entityreference autocomplete paths are defined in entityreference_menu() as:


entityreference/autocomplete/single/%/%/%
entityreference/autocomplete/tags/%/%/%


The wildcard arguments are field name, entity type and bundle respectively. The entityreference_autocomplete_callback() function also accepts an optional entity id and string parameter (the last being the search string).

So while you're expecting the path to be node/[nid], it'll actually be one of the above - which explains why arg(1) is giving you the string autocomplete.

I haven't tried it but you should be able to use arg(6) to get the node ID in your current context.