Please or Register to create posts and topics.

Subscribe to own topics automatically

PreviousPage 2 of 2
function auto_subscribe($postID, $topicID) {
  global $asgarosforum;
  $asgarosforum->notifications->subscribe_topic($topicID);
}
add_action('asgarosforum_after_add_topic_submit', 'auto_subscribe', 10, 2);

function auto_subscribe($postID, $topicID) {
  global $asgarosforum;
  $asgarosforum->notifications->subscribe_topic($topicID);
}
add_action('asgarosforum_after_add_post_submit', 'auto_subscribe', 10, 2);

Hello @asgaros

When I put the two functions in function.php of my theme, I have an error of type E_COMPILE_ERROR

Is this code better?

function auto_subscribe($postID, $topicID) {
  global $asgarosforum;
  $asgarosforum->notifications->subscribe_topic($topicID);
}
add_action('asgarosforum_after_add_topic_submit', 'auto_subscribe', 10, 2);
add_action('asgarosforum_after_add_post_submit', 'auto_subscribe', 10, 2);

 

Quote from Guillaume on September 26, 2019, 9:55 pm
function auto_subscribe($postID, $topicID) {
  global $asgarosforum;
  $asgarosforum->notifications->subscribe_topic($topicID);
}
add_action('asgarosforum_after_add_topic_submit', 'auto_subscribe', 10, 2);

function auto_subscribe($postID, $topicID) {
  global $asgarosforum;
  $asgarosforum->notifications->subscribe_topic($topicID);
}
add_action('asgarosforum_after_add_post_submit', 'auto_subscribe', 10, 2);

Hello @asgaros

When I put the two functions in function.php of my theme, I have an error of type E_COMPILE_ERROR

Is this code better?

function auto_subscribe($postID, $topicID) {
  global $asgarosforum;
  $asgarosforum->notifications->subscribe_topic($topicID);
}
add_action('asgarosforum_after_add_topic_submit', 'auto_subscribe', 10, 2);
add_action('asgarosforum_after_add_post_submit', 'auto_subscribe', 10, 2);

 

@asgaros Just checking which is best before I implement it?

function auto_subscribe($postID, $topicID) {
  global $asgarosforum;
  $asgarosforum->notifications->subscribe_topic($topicID);
}
add_action('asgarosforum_after_add_topic_submit', 'auto_subscribe', 10, 2);
add_action('asgarosforum_after_add_post_submit', 'auto_subscribe', 10, 2);

With my forum, it works perfectly

Hello @guillaume @ukbestrong

The code in the last post of Guillaume is correct. That error before happened because you were using two times a version with the same name. As you already saw its enough to just declare it once.

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!

Asgaros has reacted to this post.
Asgaros

Hi @asgaros

Would you consider integrating this code (auto subscribe after topic creation) into the settings of the plugin as a regular functionality ?

Thank you,

Regards,
Alcan

Ok, I’ve seen the restrictions about some countries about that.

Thanks for the code. I will try that.

Have a nice day!

andre

 

 

PreviousPage 2 of 2