Listing entries assigned to a specific user

Make sure to check out this course on GravityKit Academy on Advanced User Management and CRM Functionality, which covers a similar use case to this article.

If you are using Gravity Flow's Assignee field, then please check this other article instead.

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 who 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 shown in the image above, this View is unfiltered; we see 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 to the task was assigned.

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

We strongly recommend you read the article about the {user} Merge Tag, 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.

Still need help? Contact Us Contact Us