• John

    (@lordalerion)


    inside _submit.php

    There is this block of code, I am looking for it to NOT email the admin of the post, but instead email the “contact_email” of the post. Using FireBug, the ID for the contact email is _lddlite_contact_email — I am not allowing users to create accounts and instead all new submissions are created under the admin, so the emails need to be redirected to the email they provided when they created the listing. Hope it makes sense.

    Anyone have an idea how I can change this to email not the admin, but the email they listed in the post?

    /**
    * Send an email to a listing author when their listing has been updateding from pending review to published.
    *
    * @param object $post The WP_Post object
    */
    function ldl_notify_when_approved($post) {

    // Don’t send an email if this is the wrong post type or it’s already been approved before
    if (LDDLITE_POST_TYPE != get_post_type() || 1 == get_post_meta($post->ID, ‘_approved’, true))
    return;

    $user = get_userdata($post->post_author);
    $permalink = get_permalink($post->ID);
    $title = get_the_title($post->ID);

    $to = $user->data->user_email;
    $subject = ldl()->get_option(’email_onapprove_subject’);

    $message = ldl()->get_option(’email_onapprove_body’);
    $message = str_replace(‘{site_title}’, get_bloginfo(‘name’), $message);
    $message = str_replace(‘{directory_title}’, ldl()->get_option(‘directory_label’), $message);
    $message = str_replace(‘{title}’, $title, $message);
    $message = str_replace(‘{link}’, $permalink, $message);

    ldl_mail($to, $subject, $message);
    update_post_meta($post->ID, ‘_approved’, 1);

    }
    add_action(‘pending_to_publish’, ‘ldl_notify_when_approved’);

    https://www.ads-software.com/plugins/ldd-directory-lite/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter John

    (@lordalerion)

    I think this is the code to get the contact_email from the post

    $meta[’email’] = get_post_meta($id, ldl_pfx(‘contact_email’), 1);

    but I am not sure how to use it in that block code I previously posted

    Thread Starter John

    (@lordalerion)

    To be clear here, the way this plugin is setup is it requires you to login or create an account to submit a listing – I made it so when a new listing is created, it is done under the Admin.

    Now when a listing is submitted and approved, I would like an email notification not to go to the “admin” but to the email that has been entered in the listing submission.

    $meta[’email’] = get_post_meta($id, ldl_pfx(‘contact_email’), 1);

    Any ideas?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘email notification’ is closed to new replies.