Show User Info Based on a TV Part One

How to get a TV to display a drop-down list of users, and how to show information about the selected user.

By Bob Ray  |  September 30, 2026  |  3 min read
Show User Info Based on a TV Part One

MODX Forum user Andy Jones wanted a way to select a user from a list of all users in a TV and then show that user's information on the page. This is actually pretty easy. We'll see how to do it in this article.

In my previous article, we used the example of a quarterly report with a Date TV that hid the time input. In this one, we'll use a more complex example where you want to select a user from a drop-down list and show information about that use on the current page.

The Problem

Suppose you have a site showing galleries for a variety of artists. You want to show contact information for the artist on the artist's gallery page. All your artists are registered users on the site, so they can upload new images. You could write a custom snippet to show the data and enter the user's username or ID in the snippet tag, but you'd have to look up each user to confirm the username or ID. It would be much nicer if you could select the user from a drop-down list when editing their page.

The Solution

The first step is to create the TV. Let's call it "GalleryUser">. On the "Input Options" tab, set the TV Type to Listbox (single-select). Then, put this in the "Input Option Values" field:

@SELECT `username`,`id` FROM `modx_users` WHERE `active` = 1

Set the "Allow Blank" option to "No.

On the "Template Access" tab, attach the TV to the Template for the gallery artist pages.

You can leave the other fields as they are. Note that you can only have two fields in the MySQL statement. The values from the first field will be displayed in the drop-down list, the values from the second field will be stored as the TV values.

Don't forget to save the TV

Entering the Data

This involves some grunt work. You need to edit every gallery artist's page and set the value of the TV you just created. You could avoid that if there's some way to identify the artist from the page content, title, or alias. If that's the case, you could write a utility snippet to walk through all the pages and set the TV for each one.

Displaying the Results

Next, we'll use the Profile snippet to show the user's information. The Profile snippet is part of the Login package, so make sure the Login extra is installed. Put this code in the page template or the Resource Content field:

[[!Profile? &user=`[[*GalleryUser]]`]]Username: [[+username]]Full Name: [[+fullname]]Email: [[+email]]Phone: [[+phone]]

The Profile snippet will set the placeholders for all user fields.

You can use any placeholders from the user or user profile object. If you need to use extended fields, do this:

[[!Profile? &user=`[[*GalleryUser]]` &useExtended=`1`]]

Be sure that the Profile snippet tag is above all the placeholders and remember that even though you selected the username from the drop-down list, it is the selected user's ID that is stored as the TV value for that page and retrieved by the placeholder.

Coming Up

This version is nice, but it shows every user on the site. In the next article we'll see how to show just the users in a particular user group.


About Bob Ray

Bob Ray is the author of the MODX: The Official Guide and dozens of MODX Extras including QuickEmail, NewsPublisher, SiteCheck, GoRevo, Personalize, EZfaq, MyComponent and many more. His website is Bob’s Guides. It not only includes a plethora of MODX tutorials but there are some really great bread recipes there, as well.

Learn more about Bob Ray.