Support

Account

Home Forums General Issues Filter Comment Notification Text with Added ACF Field Value

Unread

Filter Comment Notification Text with Added ACF Field Value

  • I am trying to filter the default comment notification text based on an added custom field. However, the condition doesn’t seem to be working inside the function. Not sure why.

    Here is the code:

    function filter_invoice_comment_notification_text( $notify_message, $comment_id ) {
        $comment = get_comment($comment_id);
        $invoice_file = get_field('upload_invoice_comment', $comment);
        if ( $invoice_file ) {
            return $notify_message . '<br><br><a href="'.$invoice_file["url"].'">Download Invoice</a>';
        } else {
            return $notify_message;
        }
    };
    
    add_filter( 'comment_notification_text', 'filter_invoice_comment_notification_text', 10, 2 );
Viewing 1 post (of 1 total)

The topic ‘Filter Comment Notification Text with Added ACF Field Value’ is closed to new replies.