• This plugin is the right tool if you have special requirements to send email to dynamically defined user groups. It needs some php-fiddling to get it working, but definitively much less than what the dinosaurs require.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Mike Walsh

    (@mpwalsh8)

    I am curious – what PHP did you have to change to get it working?

    Thread Starter dmenne

    (@dmenne)

    What php-fiddling:
    Sorry, I was not clear; no changes in core code, we just had a series of “business-rules” (“strings” are persons playing viola or violin who have a status of “Aktiv”), and I added some filters following your example.

    It would be nice to have an example with multiple keys, I could not yet get the following concept to work (but will, for sure).
    But maybe it’s anyway better to have these in some cron-controled function.

    $args = array(
    			'meta_query' => array(
    				0 => array(
    			     'key' => $searchkey,
    			     'value' => $val[$searchkey],
    				 'compare' => '='
    			    ),
    				1 => array(
    				 'key'   => 'status',
    				 'value' => 'Aktiv',
    				 'compare' => '='
    		)));
            $uq = new WP_User_Query($args) ;
    Thread Starter dmenne

    (@dmenne)

    Just in case someone should need it:

    function send_to_streicher()
    {
        mailusers_register_group_custom_meta_filter('Aktive Streicher', 'streicher',1,"=");
    }
    
    function update_active_strings_meta_filter(){
      $newkey = 'streicher' ;
      $searchkey = 'instrument';
      $searchvalues = array(
            'Kontrabass','Cello','Violine I','Violine II','Viola'
       ) ;
      update_active_register_meta_filter($searchkey,$searchvalues,$newkey);
    }
    
    function update_active_register_meta_filter($searchkey,$searchvalues,$newkey)
    {
        $uq = new WP_User_Query(array('meta_key' => $newkey)) ;
    
        foreach ($uq->get_results() as $u)
            delete_user_meta($u->ID, $newkey) ;
        foreach  ($searchvalues as $val)
        {
    		$args = array(
    			'meta_query' => array(
    				0 => array(
    			     'key' => $searchkey,
    			     'value' => $val,
    			    ),
    				1 => array(
    				 'key'   => 'status',
    				 'value' => 'Aktiv'
    				)
    		));
            $uq = new WP_User_Query($args) ;
    
    		foreach ($uq->get_results() as $u){
                update_user_meta($u->ID, $newkey, true) ;
    		}
        }
    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘A clean-lean plugin’ is closed to new replies.