-1

We have an application that has a field to enter usernames of people who have never logged in before.

When these users log in, we want to filter these applications in a view to match their currently logged in username.

Is this possible?

Detailed explanation:

There are two roles: student and faculty. Both have sections to fill on the same node. Field permissions hides the fields of the other role. We want students to see the node that a faculty created for them in a view when they log in. Can the faculty fill out a username field (student has not logged in before) so that the view will list only the content assigned to the student?

I was thinking of using contextual filters on a taxonomy term with a default value of a PHP script that grabs the current username. However, I don't know if this is possible/practical and the PHP code I found online didn't end up working. Any thoughts or ideas?

two scripts I've tried:

global $user;
$user_uid = user_load($user->uid);
$myuserid = $user_uid->field_std_user_id['und']['0']['value'];
return $myuserid;

global $user;
$term= user_load($user->uid)->field_std_user_id;
return $term['und'][0]['tid'];
2
  • I'm still a little confused about the entire situation. Are students already registered? Do you want to list users that aren't actually users yet?
    – mradcliffe
    Jan 12, 2017 at 18:27
  • What Drupal version? Please tag your question with a Drupal version.
    – leymannx
    Jan 13, 2017 at 16:04

1 Answer 1

0

You could use Views' exposed filter to filter by username. But you will have to do some coding to get current user's name in the field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.