<p>sorry I didn't try to do this and after trying, couldn't get it to work myself... So...</p>

<p>If you have flexibility and can replace your ligthswitches with a group of checkbox, this becomes a lot easier and potentially more flexible as you could add new 'types of logo' without reviewing your plugin whereas at the moment, you would need to manually add new 'types'.</p>

<p>So, if you can, change your ligthswitches for a group of checkbox called 'logos' for example and add 2 checkbox 'Web' &amp; 'Email', then:</p>

<pre><code>public function modifyUserSources(&amp;$sources, $context)
{
    if ($context == 'index')
    {
    $sources[] = array('heading' =&gt; 'Stats Users');

    $user_criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::User);
    $user_criteria-&gt;group = 'editors';
    $user_criteria-&gt;logos = ':notempty:';

        $sources['users:memberBranding'] = array(
          'label'    =&gt; Craft::t('Logo'),
          'criteria' =&gt; $user_criteria,
      );
    }
}
</code></pre>

<p>As long as a user 'has' a logo AND is an editor, they will show in your source.</p>

<p>If you can't change the lightswitch setup, I'm afraid I don't know how to do it and I would love to find out if you manage to get it working!</p>

CC BY-SA 3.0
2015-11-18T13:45:05.693Z
2015-11-18T13:45:05.693Z
Oli
<p>If you take a look here, this should get you on the right track.</p>

<p><a href="https://craftcms.stackexchange.com/questions/9838/how-can-i-set-up-sources-based-on-my-custom-field-data/9839#9839">How can I set up sources based on my custom field data?</a></p>

CC BY-SA 3.0
2015-11-18T10:50:56.740Z
Hi Olivier. I am sorry I cannot understand how to use it because I am not having custom field on my part. Can you be a litlle bit more precise? Should I make `$user_criteria` directly with a SQL query thats it ?
migmaker
CC BY-SA 3.0
2015-11-18T09:24:00.973Z
2015-11-18T09:24:00.973Z
2017-04-13T12:51:00.160Z
Oli
<p>I am filtering users in my CP by adding a new user source.<br>
I know how to get users for specific criterias.  </p>

<p>But in this case I want to make a <code>OR</code> condition on those two users fields :<br>
<code>$user_criteria-&gt;emailLogo = true;</code><br>
<code>$user_criteria-&gt;webLogo = true;</code></p>

<pre><code>public function modifyUserSources(&amp;$sources, $context)
{
    if ($context == 'index')
    {

        // LISTING USERS
        $sources[] = array('heading' =&gt; 'Stats Users');

        $user_criteria = craft()-&gt;elements-&gt;getCriteria(ElementType::User);
        $user_criteria-&gt;group = 'myMembers';

        // THIS WILL MAKE A -AND- CONDITION (I WANT A -OR-)
        $user_criteria-&gt;emailLogo = true;
        $user_criteria-&gt;webLogo = true;

        $sources['users:memberBranding'] = array(
            'label'    =&gt; Craft::t('Logo'),
            'criteria' =&gt; $user_criteria,
        );
    }
}
</code></pre>

<elementcriteriamodel>
Use getCriteria with OR condition on multiple fields
# Use getCriteria with OR condition on multiple fields

(Asked by: username_0 on 2015-11-17)

I am filtering users in my CP by adding a new user source.
I know how to get users for specific criterias.  
But in this case I want to make a OR condition on those two users fields :
$user_criteria->emailLogo = true;
$user_criteria->webLogo = true;
public function modifyUserSources(&$sources, $context)
{
    if ($context == 'index')
    {

        // LISTING USERS
        $sources[] = array('heading' => 'Stats Users');

        $user_criteria = craft()->elements->getCriteria(ElementType::User);
        $user_criteria->group = 'myMembers';

        // THIS WILL MAKE A -AND- CONDITION (I WANT A -OR-)
        $user_criteria->emailLogo = true;
        $user_criteria->webLogo = true;

        $sources['users:memberBranding'] = array(
            'label'    => Craft::t('Logo'),
            'criteria' => $user_criteria,
        );
    }
}

**Tags:** elementcriteriamodel

---

## 2 answers

### Answer by username_1 on 2015-11-18. Score: 1

sorry I didn't try to do this and after trying, couldn't get it to work myself... So...
If you have flexibility and can replace your ligthswitches with a group of checkbox, this becomes a lot easier and potentially more flexible as you could add new 'types of logo' without reviewing your plugin whereas at the moment, you would need to manually add new 'types'.
So, if you can, change your ligthswitches for a group of checkbox called 'logos' for example and add 2 checkbox 'Web' & 'Email', then:
public function modifyUserSources(&$sources, $context)
{
    if ($context == 'index')
    {
    $sources[] = array('heading' => 'Stats Users');

    $user_criteria = craft()->elements->getCriteria(ElementType::User);
    $user_criteria->group = 'editors';
    $user_criteria->logos = ':notempty:';

        $sources['users:memberBranding'] = array(
          'label'    => Craft::t('Logo'),
          'criteria' => $user_criteria,
      );
    }
}

As long as a user 'has' a logo AND is an editor, they will show in your source.
If you can't change the lightswitch setup, I'm afraid I don't know how to do it and I would love to find out if you manage to get it working!


---

### Answer by username_1 on 2015-11-18. Score: 0

If you take a look here, this should get you on the right track.

[How can I set up sources based on my custom field data?](https://craftcms.stackexchange.com/questions/9838/how-can-i-set-up-sources-based-on-my-custom-field-data/9839#9839)

> **Comments:**
> **username_0**: Hi Olivier. I am sorry I cannot understand how to use it because I am not having custom field on my part. Can you be a litlle bit more precise? Should I make `$user_criteria` directly with a SQL query thats it ?  

---

