Support » Plugin: Comment Reply Email Notification » Is it possible to change hostname for comment link?

  • Resolved Gulshan Kumar

    (@thegulshankumar)


    Let say my WordPress site URL is https://secret.example.com (pass-protected)

    I want visitor to know comment link at www.example.com instead https://secret.example.com

    Example

    https://www.example.com/permalink/#comment-1100

    Is it possible to change the hostname in Comment notification email?

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Arno Welzel

    (@awelzel)

    You can achieve this with a custom email template. See “Customizing the email template” in the description and the existing template in templates/cren/notification.php:

    <p><a href="<?php echo get_permalink($parent->comment_post_ID) ?>"><?php echo get_the_title($parent->comment_post_ID) ?></a></p>

    You may use the following code instead:

    <p><a href="<?php echo str_replace('https://secret.example.com', 'https://www.example.com', get_permalink($parent->comment_post_ID)) ?>"><?php echo get_the_title($parent->comment_post_ID) ?></a></p>

    Just keep in mind: do not edit the file itself – this would get overwritten by the next update! Make a copy as described to your theme (/wp-content/themes/[THEME]/templates/cren/).

    • This reply was modified 1 month, 1 week ago by Arno Welzel.
    Gulshan Kumar

    (@thegulshankumar)

    Hi Arno,

    Thanks for your response. It worked for the Post link.

    There are two more links in the email. How do I modify them as well?

    
    <p><a href="<?php echo get_comment_link($parent->comment_ID) ?>"><?php echo __('Click here to reply', 'comment-reply-email-notification') ?></a></p>
    
    <p><a href="<?php echo cren_get_unsubscribe_link($parent) ?>"><?php echo __('Click here to stop receiving these messages', 'comment-reply-email-notification') ?></a></p>
    

    I tried –

    
    <h2><?php printf(__('Hi %s', 'comment-reply-email-notification'), $parent->comment_author) ?>,</h2>
    
    <p><?php printf(__('%s has replied to your comment on', 'comment-reply-email-notification'), $comment->comment_author) ?></p>
    
    <p><a href="<?php echo str_replace('https://secret.example.com', 'https://www.example.com', get_permalink($parent->comment_post_ID)) ?>"><?php echo get_the_title($parent->comment_post_ID) ?></a></p>
    
    <p><em><?php echo esc_html($comment->comment_content) ?></em>
    
    <p><a href="<?php echo str_replace('https://secret.example.com', 'https://www.example.com', get_comment_link($parent->comment_ID) ?>"><?php echo __('Click here to reply', 'comment-reply-email-notification') ?></a></p>
    
    <p><a href="<?php echo str_replace('https://secret.example.com', 'https://www.example.com', cren_get_unsubscribe_link($parent) ?>"><?php echo __('Click here to stop receiving these messages', 'comment-reply-email-notification') ?></a></p>
    

    but got ‘There has been a critical error on your website. Learn more about debugging in WordPress.’ while replying comment.

    The access.log said 'PHP message: PHP Parse error: syntax error, unexpected '?>', expecting ')''

    Thanks again!

    Gulshan Kumar

    (@thegulshankumar)

    I added missing round brackets, it worked 🎉

    
    <h2><?php printf(__('Hi %s', 'comment-reply-email-notification'), $parent->comment_author) ?>,</h2>
    
    <p><?php printf(__('%s has replied to your comment on', 'comment-reply-email-notification'), $comment->comment_author) ?></p>
    
    <p><a href="<?php echo str_replace('https://secret.example.com', 'https://www.example.com', get_permalink($parent->comment_post_ID)) ?>"><?php echo get_the_title($parent->comment_post_ID) ?></a></p>
    
    <p><em><?php echo esc_html($comment->comment_content) ?></em>
    
    <p><a href="<?php echo str_replace('https://secret.example.com', 'https://www.example.com', get_comment_link($parent->comment_ID)) ?>"><?php echo __('Click here to reply', 'comment-reply-email-notification') ?></a></p>
    
    <p><a href="<?php echo str_replace('https://secret.example.com', 'https://www.example.com', cren_get_unsubscribe_link($parent)) ?>"><?php echo __('Click here to stop receiving these messages', 'comment-reply-email-notification') ?></a></p>
    
    Plugin Author Arno Welzel

    (@awelzel)

    Thanks for your feedback and your donation! I really appreciate this.

    Gulshan Kumar

    (@thegulshankumar)

    You’re more than welcome.

    Loving this plugin. Was looking for this kind of plugin since many years.
    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.