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

    • futaba

    • June 26, 2020 at 9:27 pm

    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)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.