WordPress.org

Ready to get started?Download WordPress

Forums

Email Users
[resolved] Email to user meta field (33 posts)

  1. Andy Fragen
    Member
    Posted 1 year ago #

    Sending to a user role is great but I'd also like to be able to email to a specific user meta field. Any thoughts of a feature request?

    http://wordpress.org/extend/plugins/email-users/

  2. Mike Walsh
    Member
    Plugin Author

    Posted 1 year ago #

    I am not sure what that means - can you elaborate on what you want to do?

  3. Andy Fragen
    Member
    Posted 1 year ago #

    I'm using the Cimy User Extra Fields plugin and I'd like to be able to send email based upon the value of a specific extra field.

  4. thomaslcq
    Member
    Posted 1 year ago #

    I'd be interested to have some filter/hook so I could provide custom lists/groups to the plugin, would that be possible? That would be something like

    apply_filters('emailusers_customgroup','mycustomgroups')
    
    function mycustomgroups() {
    
    //build my custom list based on their meta "interest"
    $groups = array(
                array(name=>"Group1", users=> array(id1,id2,id3)),
                 ...
                 )
    return $groups;
    }

    (raw php code, unchecked, but pseudocode :)

  5. Mike Walsh
    Member
    Plugin Author

    Posted 1 year ago #

    If we're talking about simply sending an email and not post and/or page notifications, a filter to select the recipients is certainly possible and probably not difficult to implement.

    The challenge becomes how to presented something in the WordPress UI in the general case that would allow the plugin and/or theme to define the subset of users that should be in the recipient list.

    I'll think about this as I can definitely see an application for it and see what I can do. I've got some other things stacked up that I need to finish first but will put this on the to-do list.

  6. thomaslcq
    Member
    Posted 1 year ago #

    Great to read so ! I wasn't really thinking of the wp UI either, but that's indeed a challenge... I'm more of a hacker, so if a filter is available, my plugin can talk to your plugin :) But the UI would be interesting for others, surely !

    let me know if you want to have some discussion about it

    cheers,

  7. Andy Fragen
    Member
    Posted 1 year ago #

    Just sending an email would be enough for me. A quick search lead me to this, . I don't know if it's useful.

    A filter would work for me as well. Thanks for putting it on the todo list.

  8. Andy Fragen
    Member
    Posted 1 year ago #

    After digging into this more I think a filter is the simplest way to go. It will be extraordinarily difficult to figure out what someone else's custom user fields are.

    So a filter sending email to every user with a specific key value pair where the filter would take as parameters the key and an array of values. Then I could select the specific value from my array.

    Pseudo code above would work.

  9. Andy Fragen
    Member
    Posted 1 year ago #

    BTW, not using Cimy plugin as it doesn't create "real" user meta fields.

  10. Mike Walsh
    Member
    Plugin Author

    Posted 1 year ago #

    I've spent some thinking about this and I agree, a filter is probably the best way to do it. I need to finish up a couple other things I am working on before I can tackle this but now that v4.3.15 has been released, this should be next on my to-do list unless I get any other bug reports.

  11. Andy Fragen
    Member
    Posted 1 year ago #

    Excellent. Only thing I would suggest would be input array similar to the following.

    array( [meta-field-name] => "Meta Field Label", [meta-field-values] => array('value1,value2,value3) )

    Where meta-field-name is user's declared meta field name and label is similar to how role currently displayed and meta-field-values is just an unordered array with the values. But obviously the only necessary data is the array of values. Labels just keep it more ordered if lots of meta fields are needed.

  12. Andy Fragen
    Member
    Posted 1 year ago #

    Mike,

    I've done a bit of testing from my installation. I've got a couple of script that should return an array of values for a given custom user meta field and return a array of email addresses for a given custom user meta field and a designated value for this field.

    https://gist.github.com/4137084

    the format for the call is as follows

    get_user_meta_field_values( 'my-custom-meta-field' );
    returns an array of the values for the designated custom user meta field.

    get_email_from_meta( 'my-custom-meta-field, 'custom-meta-value' );
    returns an array of email addresses corresponding to users with that particular custom meta value.

    I hope this helps in some way.

  13. Andy Fragen
    Member
    Posted 1 year ago #

    I reworked the script to use a single call with the returned array being different depending upon what variable are passed.

    get_user_meta_field_data( 'my-custom-user-meta-field' ); returns an array with the values of the custom user meta field.

    get_user_meta_field_data( 'my-custom-user-meta-field', my-custom-user-meta-field-value' ); returns an array of email addresses of all users with that particular custom user meta field value.

  14. Andy Fragen
    Member
    Posted 1 year ago #

    Hey Mike, any time to think about this?

  15. Mike Walsh
    Member
    Plugin Author

    Posted 1 year ago #

    Unfortunately I haven't much time to do anything WordPress related recently. This is a very busy time of the year for me at work so free cycles are few and it will probably stay that way through the end of the month (our fiscal year ends on 1/31).

    Wish I had better news to share. I have 3-4 things I want to implement for Email-Users, this is one of them.

  16. Andy Fragen
    Member
    Posted 1 year ago #

    No problem Mike. I just wanted to know if it was still on your radar. I hope the code is helpful.

  17. Mike Walsh
    Member
    Plugin Author

    Posted 1 year ago #

    While I am looking at another issue today, I am looking at whether or not I can add this at the same time.

    Do you think the filter should supersede the standard settings for Mass Email and Post/Page Notifications or should it be another Send Option completely? I am inclined to make it a new Send option so you would have "Send to User(s)", "Send to Group(s)" and a new item "Send to Custom List" (or something similar) that would only appear if the filter was defined.

    Thoughts?

  18. Andy Fragen
    Member
    Posted 1 year ago #

    I agree with making it another send option that is only visible if the custom user meta is defined.

  19. Mike Walsh
    Member
    Plugin Author

    Posted 1 year ago #

    I have posted a beta release that has this requested functionality. Please check it out and let me know if it allows you to do what you want to do.

  20. Andy Fragen
    Member
    Posted 1 year ago #

    Hey Mike, this new beta does work but I was expecting something that would work more like 'Send to Groups' rather than 'Send to Users'.

    I guess I wanted something more along the lines of

    mailusers_register_custom_meta_filter($label, $meta_filter);

    This would then return a page similar to 'Send to Groups' where I would select the '$label - $meta_value' from the list. The $meta_value would be returned automatically based upon all the returned values for $meta_filter.

    In my case something like the following

    mailusers_register_custom_meta_filter('Department', 'drmc_department');

    I would want this to return the array of values to select from in a group like

    Department - Medicine
    Department - Surgery
    Department - Pediatrics
    etc

    This would work the same way selecting a Role works.

    That way I could make only a single add_action for each $meta_filter. If I wanted to keep the more fine grained search as currently exists then what you've got works.

    Does that make sense?

  21. Mike Walsh
    Member
    Plugin Author

    Posted 1 year ago #

    Yes, what you've outlined makes sense. Let me see what I can do. I'll probably break it up into two things - Custom User Filter and Custom Group Filter. Looks like I was 0-2 on your issues!

  22. Andy Fragen
    Member
    Posted 1 year ago #

    Credit where credit is due. As a dev your looking at my issues and feature requests. ;-)

    Maybe 0.5 - 2, after all I can now send to groups based upon meta values, just not how I was thinking. If you want I can set up some data on my dev site, get you some admin credentials and you can test there if you want.

  23. Mike Walsh
    Member
    Plugin Author

    Posted 1 year ago #

    I have released another beta candidate that I think will address the use model you are looking for. Let me know what you think.

  24. Andy Fragen
    Member
    Posted 1 year ago #

    Mike, this isn't substantially different. It's just in this version with groups I can't see to whom the email is addressed, not that it matters. I still have to individually add each $meta_filter and $meta_value to the function.

    What I was envisioning, and what the code I made does, is to enable the user to just list the $meta_filter and have the code return an array of all the $meta_values for that $meta_filter. The code would place something like 'Filter - $label - $meta_value[$i]' for the whole list of meta_values that correspond to the listed meta_filter.

    The function would only have 2 parameters ($label, $meta_filter) as the $meta_values would be discovered.

  25. Andy Fragen
    Member
    Posted 1 year ago #

    If you want to put this up on Github I'd be happy to help.

  26. Mike Walsh
    Member
    Plugin Author

    Posted 1 year ago #

    I had some time work on this on my flight to Phoenix this week and have just uploaded a new beta version which I think is closer to what you are looking for. Details are here.

  27. Andy Fragen
    Member
    Posted 1 year ago #

    Brilliant! Works exactly as I expected.

  28. Mike Walsh
    Member
    Plugin Author

    Posted 1 year ago #

    Excellent news. I will try and get an update out in the next day or so.

  29. Graham Stacey
    Member
    Posted 1 year ago #

    Andrew,
    I too am trying to implement this and am grateful to Mike for working hard to add this function.
    I wonder how you got this too work with Cimy User Extra Users fields. I can't see how to address the actual field, which in my case is called DIOCESE within Cimy.

    Grateful for any clues
    thank you

  30. Andy Fragen
    Member
    Posted 1 year ago #

    Graham, I couldn't use Cimy User Extra as it doesn't create real user meta fields. You'll need to create real user meta fields from other code or another plugin.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.