Getting the uid from user name for a view argument I'm loading content from a third party system to Drupal using the Feeds and Data modules. Drupal will be used as an intranet, the users will be able to log in and see their account records (the data I'm getting into Drupal). One of the fields has the user name (not the user id), so in the external system a record can be referenced to each user.

In views is posible use the uid as an argument and show content that references to that uid. Is there a way that I can use the user name as an argument and show the content if that user is logged in or viewing his/her user profile?

Data module does not allow relationships when creating a view.

I suppose I can insert PHP code, use the user name then load de uid, and use de uid as validator in views, I'm not a PHP expert and I'm not sure if that is the correct way to do it.

Thanks in advance for your advices.
Use the Data name argument to filter the results by. Each content field has it's own argument that you can choose to filter the results by.

(edit: reply to comment) Let's say that your drupal username is user3 with a UID of 3. The user ID of the external data will be user3? So when the user goes to mysite.com/user/3 the argument will be 3 which doesn't help with the external data because that needs to be mapped to user3? If the user ID of the external data is 3 then you can use data: field_userID or whatever it is and get arg(1) using provide default value from PHP code, page manager or Views Arguments from Context. Now, if you to map the Drupal username to the external data username/user ID which is user3 then use provide default value from PHP code, get the global $user variable and use $user->name for the argument. This maps the user's name to the database column in the data table and returns (filters) all results/ database rows with that username in that column.

Don't validate it until you get it working.

global $user;
return $user-&gt;name;


or

return arg(1);