Jump to content

Create front end search based on the User template


Krlos
 Share

Recommended Posts

Hello, I'm trying to create a front end search from custom fields stored in the user system template.

For example I've created a custom field "last_name", what selector can I use to find all the users with "smith" last name in my users table?

and how how to combine search terms?, for example to match a search for last name "smith" that have a status of married (married also a custom field in the user template)

Thank you

Link to comment
Share on other sites

$u = $users->find("last_name=Smith");
foreach($u as $uu) {
    echo "{$uu->first_name} {$uu->last_name}<br>";
}

// combine: (marital_status is a page-reference field in my test setup)
$u = $users->find("marital_status=divorced, last_name=Smith");
foreach($u as $uu) {
    echo "{$uu->first_name} {$uu->last_name}, {$uu->marital_status->title} <br>";
}

 

  • Like 4
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...