Please or Register to create posts and topics.

New Topic Subscription Notification – Full topic article or excerpt

Hi. I’ve received an email because I’m a subscriber for New Topics. However I noticed that it emailed me the whole post (although it was a short post).

If someone posts a New Topic that is long, I would only want an excerpt of it to show up in emails for people who subscribe for New Topics.

How can I set it to excerpts instead of sending out the whole post in the email to subscribers?

Thanks

Hello @fernandolawl

You can use the following code-snippet to show (for example) onle the first 100 characters of an answer when a new topic is generated:

function my_excerpt($replacements, $user_object) {
  global $asgarosforum;

  if (isset($replacements['###CONTENT###'])) {
    $replacements['###CONTENT###'] = $asgarosforum->cut_string(strip_tags($replacements['###CONTENT###']), 100);
  }

  return $replacements;
}
add_filter('asgarosforum_user_replacements', 'my_excerpt', 10, 2);

Please add the code to your themes functions.php file.

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Thank you so much!

How about for when someone posts a reply to a topic?

There is also a filter for this which is called asgarosforum_filter_notify_topic_subscribers_message. The code should be almost the same but you have to play around a little bit with the message-text.

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Thank you for the reply. I’m not familiar with filters. So I googled “asgarosforum_filter_notify_topic_subscribers_message” and found other forums which you contributed to that has the same question I had.  As other people said, I do not have the experience to create a plugin thus this may seem like a difficult task for me to accomplish.

I hope you’ll be able to add the option for us to manage the email reply topics lengths in a future update.

Thank you for your help

Best regards!

Hello @fernandolawl

Thanks for your reply. Yes, I am aware that the current state of modifying the notification-logic is not really straight-forward. I will try to implement more configuration possibilities in a future update.

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!

Hi

I added this code via code snippets but the desired result is not achieved

This is what I get in email instead of an 100 word excerpt

all blank fields with no link

regards

Heinz

 

Hello,

You received this message because there is a new forum-topic:
Array

Author:

Text:

Link to the new topic:

Hello @heinzomnivision-co-za

Yes, the code has changed. Please try to use the following one:

function my_excerpt($replacements, $user_object) {
  global $asgarosforum;

  if (isset($replacements['###CONTENT###'])) {
    $replacements['###CONTENT###'] = $asgarosforum->cut_string(strip_tags($replacements['###CONTENT###']), 100);
  }

  return $replacements;
}
add_filter('asgarosforum_user_replacements', 'my_excerpt', 10, 2);

 

If you want to support the development of Asgaros Forum, you can leave a good review or donate. Thank you very much!