Forums

Send email on attachment page (3 posts)

  1. mhhenn
    Member
    Posted 1 year ago #

    Hello everyone.

    I am trying to make this simple plugin to just run when is a comment from the attachment file, but for some reason when I put the code in a if is_attachment() it doesn't work...

    When I comment out the if statement it works.

    Any ideas? thanks!


    function notify($comment_id) {

    if(is_attachment()) {
    $user_email = 'mhhenn@gmail.com';

    $subject = $comment_id . get_option('blogname');

    $t1 = 'Someone commented on a your picture';

    $t2 = "click here to see the comment";

    wp_mail( $user_email, $subject, $text );

    }
    }
    add_action('comment_post', 'notify');

  2. mhhenn
    Member
    Posted 1 year ago #

    More info:

    If I the add_action inside the function and then call the function in the attachment file, it works but doesn't get the $comment_ID, what is really important...

    
    function notify($comment_id) {
    
    $user_email = 'example@gmail.com';
    
    $subject = $comment_id . get_option('blogname');
    
    $t1 = 'Someone commented on a your picture';
    
    $t2 = "click here to see the comment";
    
    text = $t1 . $t2;
    
    wp_mail( $user_email, $subject, $text );
    
    add_action('comment_post', 'notify');
    
    }
    
    Ideas?
    
  3. mhhenn
    Member
    Posted 1 year ago #

    Help please!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags