Plugin Directory

Changeset 1271540


Ignore:
Timestamp:
10/23/2015 06:15:15 AM (10 years ago)
Author:
Raulanton
Message:

20151023 v1.1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • email-mentioned/trunk/email-mentioned.php

    r1186832 r1271540  
    1 <?php
     1<?php
    22/*
    33Plugin Name: Email Mentioned
    4 Plugin URI: http://wordpress.org/extend/plugins/XXXXXXXXX
     4Plugin URI: https://wordpress.org/plugins/email-mentioned/
    55Description: Send a customizable email to each user mentioned in a comment. The mention character/string is also customizable (for instance @, like in Twitter).
    6 Version: 1.01
     6Version: 1.1
    77Author: Raúl Antón Cuadrado
    88Author URI: http://about.me/raulanton
     
    8080if ( ! function_exists('antonem_sendmail') ) :
    8181function antonem_sendmail($comment_id, $approval_status=" "){
     82
     83
    8284
    8385    //Get customization values
     
    102104    $commenter = get_userdata($comment->user_id)->display_name;
    103105
     106
    104107    // Get an array with all the people cited
    105108    $people_mentioned_d = preg_split("/[\s,]+/", $comment->comment_content);   
    106109    $people_mentioned = array_unique((preg_grep("/^".$qualifier.".*/", $people_mentioned_d)));
     110
    107111
    108112    if (count($people_mentioned)>0){
     
    133137
    134138        //Send the message to each one mentioned
     139        echo "logitud".count($people_mentioned);
    135140        foreach($people_mentioned as $participant_mentioned)
    136141        {
    137             $email= get_userdata(antonem_userid_by_displayname(substr($participant_mentioned, 1)))->user_email;
     142       
     143            $email= get_userdata(antonem_userid_by_displayname(substr($participant_mentioned, 1)))->user_email;
    138144                if ($email != "")
    139145            {
    140                 wp_mail( $email, $the_subject, $the_message  );
     146            wp-email ($email, $the_subject, $the_message);
    141147            }
    142148        }
    143149
    144 
    145 
    146150    }
     151exit;
    147152}
    148153add_action('comment_post', 'antonem_sendmail');
     
    161166
    162167    $user_query = new WP_User_Query( array(
    163                 'meta_key' => 'display_name',
    164                 'meta_value' => $display_name,
     168
     169                'search' => $display_name,
     170                    'search_columns' => array( 'display_name' ),
     171
    165172                'fields' => 'ID',
    166173                'number' => 1 
     
    168175
    169176    $ids = $user_query->get_results();
     177
     178
    170179
    171180    if (!empty($ids)) {
     
    180189
    181190}
     191
     192   
     193function add_display_name_to_user_queries( $search_columns, $search, $this ) {
     194    $search_columns[] = 'display_name';
     195    return $search_columns;
     196}
     197
     198add_filter( 'user_search_columns', 'add_display_name_to_user_queries', 10, 3 );
    182199
    183200endif;
Note: See TracChangeset for help on using the changeset viewer.