Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
I'm using Extended Users, with a list of about 3500 users. Sometimes I need to find users by email address - usually because they've messed up entering their names!

I've added the email address to the list view like this:
Code: Select all
<cms:config_list_view   searchable='1'>
   (...)
   <cms:field 'extended_user_email' header='email'/>
   (...)
</cms:config_list_view>

...but sorting by email address doesn't work (it does something, but the result is not a sorted list!), and searching for an email address doesn't work either.

Any suggestions?
Bad news, it is a non-searchable field (see extended/extended-users.php::211), so won't work as you'd expect. :roll:

The problem is not a workaround, as there are some, but the already present thousands of users. If you could throw in a datatable, it would shift the burden of sorting and searching to its script i.e. in browser, but I understand it will take hours to get together.

Server-side workaround is a dummy searchable (and hidden) field taking a value of the original field and used in order/filter. However, there got to be a one-time script to resave all extended pages for the change to be picked up.
Hmm. Pity.

As a workround, I can search emails like this:

Code: Select all
<h2 class="subtitle">Search Users by Email</h2>
    <cms:form method="post">
        <cms:if k_success >
            <h3>Form successfully submitted</h3>
            <cms:show frm_email />
            <cms:query sql="SELECT name FROM couch_users WHERE email='<cms:show frm_email/>'" limit='1'>
            <cms:set u_name = "<cms:show name />" 'global'/>
            </cms:query>
          User Name: <cms:show u_name />

[...do what you want using the user name here...]

        </cms:if>
        <cms:if k_error >
            <h3>Failed to submit form</h3>
        </cms:if>

        Email: <cms:input  type="text"  name="email" validator='email'/>
          <cms:if k_error_email ><cms:show k_error_email /></cms:if> <br />
        <cms:input name="submit" type="submit" value="Submit" />
    </cms:form>
</cms:if>

I've incorporated this into a front-end form, with access limited to admins, which:
  • if given a user name as a 'get' query) shows useful details of the user and gives the option to delete or edit;
  • if there's no user name provided, it shows this form for the email and on the form action then redirects to itself with the username added to the query string.
Very good workaround! :) Same form can be injected to the list view, perhaps, overriding default search box, if search string matches email. I haven't experimented with that yet, though. Thanks for posting.
4 posts Page 1 of 1
cron