Listing entries assigned to a specific user

It's pretty easy to only display entries created by the currently logged-in user on GravityView by using our Advanced Filters. 

But, what if you want to display entries assigned to the currently logged-in user which did not create the entries?

In this short tutorial, we'll find out how to display a nice drop-down field on your form to list all your WordPress Users which we can then use to "assign" an entry to another user.

In our example, we'll create a simple form to assign tasks to other users.

Step 1: Preparing our Form

Our form will consist of 4 fields:

  • One name field;
  • One email field;
  • One drop-down field, which will dynamically populate with your WordPress Users;
  • And a paragraph field for the task description.

To dynamically populate the drop-down field with the WordPress Users of the website, we'll use a Gravity Wiz' Perk called Populate Anything

If we preview our form now, we'll see the drop-down automatically populated with the existing WordPress Users. The value of each option (user) is their WordPress user ID, perfect!

Now, save your form, click on Preview, and assign some test entries to all your WordPress Users. 

Step 2: Creating our View

Let's create a View using the Table View layout, to make it simple for this tutorial:

As we can see in the image above, this View is unfiltered, we are seeing tasks assigned to all users. Now, let's implement a filter on this View using the Advanced Filter extension and the {user} Merge Tag to only display entries assigned to the currently logged-in user:

The {user} Merge Tag will be used to output to the filter the ID of the currently logged-in user. This way we can compare it against the value of the drop down field which contains the user ID of the person that task was assigned to.

Now, let's log in on our website as Floaty and check our assigned tasks:

We strongly recommend you read the article about the {user} Merge Tag, which is a powerful tool that can be used to retrieve any data from the currently logged-in user, even custom user meta can be used to compare against any form field.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.