Current User: Guest
 
Search Forums:


 




Filtering on other usermeta

UserPost

8:29 pm
September 23, 2008


jossif

Member

posts 3

1

I love this plugin and it works flawlesly...

Now, if I just could filter not only on roles, but on other usermeta keys that will be great... You see, my blog is multilingual and I capture during registration the user's language, which is saved in wp_usermeta under meta-key="language"

How difficult would be to add a form "Send to language" as in:

Individual users | User groups | User language

Any help would be appreciated

1:38 am
September 26, 2008


jossif

Member

posts 3

2

So this is what I did:

Changed email_users_user_mail_form.php

<?php
                    $meta = "language";
                    $users = mailusers_get_users($user_ID, $meta);
                    foreach ($users as $user) {
                ?>
                    <option value="<?php echo $user->id; ?>" <?php
                        echo (in_array($user->id, $send_users) ? ' selected="yes"' : '');?>>
                        <?php echo __('User', MAILUSERS_I18N_DOMAIN) . ' - ' . $user->display_name . ' -  '. $user->language; ?>
                    </option>


And changed email-users.php:

function mailusers_get_users( $exclude_id='', $meta_filter = '') {
    global $wpdb;

    $additional_sql_filter = "";

    if ($meta_filter=='') {
        if ($exclude_id!='') {
            $additional_sql_filter = " WHERE (id<>" . $exclude_id . ") ";
        }

        $users = $wpdb->get_results(
              "SELECT id, user_email, display_name "
            . "FROM $wpdb->users "
            . $additional_sql_filter );
    } else {
        if ($exclude_id!='') {
            $additional_sql_filter .= " AND (id<>" . $exclude_id . ") ";
        }
        $additional_sql_filter .= " AND (meta_key='$meta_filter') ";
        $additional_sql_filter .= "order by meta_value, display_name";
       
        $users = $wpdb->get_results(
              "SELECT id, user_email, display_name, meta_value as $meta_filter "
            . "FROM $wpdb->usermeta, $wpdb->users "
            . "WHERE "
            . " (user_id = id)"
            . $additional_sql_filter );
    }

    return $users;
}

3:04 pm
September 26, 2008


Vincent

Admin

Lima, Peru

posts 169

3

That's good I think. What you could do is:

  1. Instead of modifying email_users_user_mail_form.php, create a copy named email_users_meta_mail_form.php
  2. Instead of changing mailusers_get_users, create a new function mailusers_get_users_from_meta that you would call in your email_users_meta_mail_form.php file
  3. In all the email_users_XXXX_mail_form.php, around line 51 in the "&lt;ul class="subsubsub"&gt;, add a link to your new form to make it appear just like "Individual users | User groups | User language".

This should be it. Thanks for publishing your modification.

4:15 pm
September 26, 2008


jossif

Member

posts 3

4

Thanks for the tip.

What would be nice is to have a way to display just the languages, rather than user |Language

-- Jossi



Reply to Topic: Filtering on other usermeta

NOTE: New Posts are subject to administrator approval before being displayed

Guest Name (Required):

Guest EMail (Required):

Guest URL (required)

Math Required!
What is the sum of: 5 + 9        (Required)

Topic Reply:


 
 

About the Development Pages forum

Currently Online:

3 Guests

Maximum Online: 43

Forums:

Groups: 7

Forums: 19

Topics: 113

Posts: 358

Members:

There are 203 members

There are 1 guests


Vincent has made 169 posts

Top Posters:

Chris F. Masse - 11

maurizio - 8

kevlewis - 6

Petra - 6

Blegoo - 5

Administrator: Vincent | Moderators: Vincent


© Simple:Press Forum - Version 3.1.2 (Build 340)