Different entity types for one field value I have a content type "Application".  And "Site Administrator" and "Developer" users are allowed to add it.

If logged-in user is "Site Administrator", the value of "Author" field will be the reference of other content type. So, in the respective field table,

entity_type : node, bundle : {content-type-name}

If logged-in user is "Developer".  I'd like to save current logged-in user id as the value of "Author" field.

entity_type : user, bundle : user

How could I get it with drupal?

Thanks in advance.
The "author" field would be a User Reference field.
You can use hook_form_alter to limit this fields allowed $options to be either the logged in user, or the list of users of Developers.


Something similar too ...

function MYMODULE_hook_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  global $user;
  if ($form_id == 'node_add_application') {
    if (in_array('Developer', $user-&gt;roles)) {
      // Set the default value of the author field to the logged in users uid.
      $form['field_AUTHOR_FIELDNAME']['options']['#default_value'] = $user-&gt;uid;
    }
    if (in_array('Site Administrator', $user-&gt;roles)) {
      // Overwrite the general users list with UIDs only of a specific role.

      // Get uids of a specific role.
      $query = 'SELECT DISTINCT(ur.uid) 
          FROM {users_roles} AS ur
          LEFT JOIN roles r on ur.rid = r.rid
          WHERE r.name = :role';
      $result = db_query($query, array(':role' =&gt; 'Developer'));
      foreach ($result as $row) {
        $developer_uids[] = $row-&gt;uid;
      }
      foreach ($form['field_AUTHOR_FIELDNAME']['options'] as $uid =&gt; $label) {
        if (!in_array($uid, $developer_uids)) {
          unset($form['field_AUTHOR_FIELDNAME']['options'][$uid];
        }
      }
    }
  }
}


This is a rough example of the logic and code it would take to alter the select list of user names for the author field to either default to the logged in developer, or show "site admins" only developers.

I have written such code before, this exact code is only an example based upon the details given in your question. It is un-tested.