Support » Plugin: Custom Comment Notifications » Add Post Category?

  • Resolved Luke Piper

    (@luke-piper)


    I’d like to add the Category of the Post into the comment moderation email subject line. Can this be done with your plugin?
    I have multiple contributors and I need to route the email to them based on a post category to a shared inbox for them.
    Or, do you plan on creating a user designation to apply specific email addresses to specific post authors (different than their user profile email), since that’s a function you already have built in?
    It might require creating a database?
    If you don’t know or do not plan on that development, will you share a suggestion for me?
    Thank you.

    https://wordpress.org/plugins/custom-comment-notifications/

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

    (@scweber)

    Thank you for using the plugin!

    I’ll need to think about adding the Post Category variable. The problem I see with this implementation is when there are multiple categories for an individual post. I’ll need to play around with this idea and maybe come up with a potential solution.

    I plan on adding the ability to add a comma-delimited list of e-mails that will get notified with the Author templates. However, I believe this is different than what you were implying. I only plan on sending the e-mail to the Author’s e-mail that is listed in their user profile.

    How comfortable are you with editing code? I could provide you with the code to adjust the plugin to include the Category for your specific situation.

    Thread Starter Luke Piper

    (@luke-piper)

    That is very generous of you. Although I’m very familiar with WordPress I am just a beginner learning to code php. Although I can’t, I do have a developer helping me. Will you send it?
    I’m new to these forums. How do I get you my contact info without publicly posting it?

    Plugin Author scweber

    (@scweber)

    Let me code it up and test that it’s working and then I’ll just post here what I did. That way, if anyone else wants to make the change or a similar change they can do so.

    Plugin Author scweber

    (@scweber)

    If you add the following code after the variable replacement (lines 624 and 833), then you can include the “P_CATEGORY” variable and it will take the FIRST category for post and insert it. If your post only has one category this works great. If your post has multiple categories, then remember that this will only return the first category.

    // Code to include the first post category
    $categories = get_the_category($P_ID);
    $P_CATEGORY = $categories[0]->cat_name;
    $notify_message = preg_replace("/\bP_CATEGORY\b/u", $P_CATEGORY, $notify_message);
    $subject = preg_replace("/\bP_CATEGORY\b/u", $P_CATEGORY, $subject);

    Please let me know if you run into any problems with this code segment.

    Thread Starter Luke Piper

    (@luke-piper)

    Thank you scweber.
    Actually that will work. We do have multiple categories but for the contributors we’ll need this for they’re already been role restricted to one category.
    Thanks again.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add Post Category?’ is closed to new replies.