Completed

Modificar funcion enviar Mail

Published on the April 09, 2018 in IT & Programming

About this project

Open

Hola  buen dia!
te consulto lo siguiente
cuando un Cliente publica un proyecto y coincidan -solo- los Skills, se envia un mail diciendole que tiene un nuevo proyecto ....

Ahora bien, yo necesito agregar que cuando coincida no solamente skill sino tambien la categoria, y

Es decir necesito que cuando reuna esas dos coincidencias de manera conjunta, se envie el mail



El archivo que maneja la funcion de enviar mail es el siguiente:

(se puede ver que tiene una actualizacion y antes enviaba mail cuando coincidia la categoria, yo necesito que se den las dos juntas)

mailing.php
    /**
     *
     *
     * @param object $project
     *
     * @since 1.0
     * @author ThanhTu
     *
     * @since 2.0
     * Update function change category to skill
     * @author Vosydao
     */
    function new_project_of_category( $project ) {
        global $ae_post_factory, $post;

        $post_object = $ae_post_factory->get( PROFILE );
        // Get term_id parent if that term have parent
        //$project_categories = $project->project_category;
        $project_categories = array();
        if(!empty($project->tax_input['skill'])){
            /*foreach ( $project_categories as $key => $value ) {
                $term = get_term( $value, 'project_category' );
                if ( $term->parent && ! in_array( $term->parent, $project_categories ) ) {
                    array_push( $project_categories, $term->parent );
                }
            }*/

            foreach ( $project->tax_input['skill'] as $key => $value ) {
                $project_categories[] = $value->term_id;
            }

            $args = array(
                'post_type'      => profile,
                'post_status'    => 'publish',
                'tax_query'      => array(
                    array(
                        //'taxonomy' => 'project_category',รบ
                        'taxonomy' => 'skill',
                        'field'    => 'term_id',
                        'terms'    => $project_categories,
                        'operator' => 'in'
                    )
                ),
                'meta_query'    => array(
                    array(
                        //'key'    => 'et_receive_mail',
                        'key'    => 'email_skill',
                        'value'  => 1,
                        'compare' => "="
                    )
                ),
                'posts_per_page' => - 1
            );

            $query    = new wp_query( $args );
            $postdata = array();
            if ( $query->have_posts() ) {
                while ( $query->have_posts() ) {
                    $query->the_post();
                    $convert      = $post_object->convert( $post );
                    $display_name = get_the_author_meta( 'display_name', $convert->post_author );
                    $user_email  = get_the_author_meta( 'user_email', $convert->post_author );
                    if ( ! empty( $display_name ) && ! empty( $user_email ) ) {
                        $postdata[] = "{$display_name} <{$user_email}>";
                    }
                }
            }

            $subject  = __( 'new project for you today!', et_domain );
            $headers[] = 'content-type: text/html; charset=utf-8';
            $headers[] = 'from: ' . Get_option( 'blogname' ) . ' <' .
Get_option( 'admin_email' ) . '>' . "\R\n";
            $headers[] = 'Bcc: ' .
Implode( ',', $postdata ) . '\R\n';

            $template_default = "<p>Hi there,</p><p>There is a new job for you today. Hurry apply for this project [project_link] and get everything started.<
/P><p>Hope you have a highly effective Day</p>";
            $mail_template    = ae_get_option( 'new_project_mail_template', $template_default );
            $link            = "<a rel='nofollow noopener noreferrer' target='_Blank' href='" . $Project->permalink . "'>" .
$Project->post_title . "</a>";
            $mail_template    = str_replace( '[project_link]', $link, $mail_template );

            // send mail
            $mail = $this->wp_mail( get_option( 'admin_email' ), $subject, $mail_template, array(), $headers );
        }
    }
}

Category IT & Programming
Subcategory Web development
What is the scope of the project? Small change or bug
Is this a project or a position? Project
I currently have I have the design
Required availability As needed
Roles needed Developer

Delivery term: Not specified

Skills needed

Other projects posted by S. C.