You need to log in to create posts and topics.

Critical error on publishing a new topic

Hi!

When someone publish a new topic appears the error message below:

image

This problem only occurs when someone creates a new topic but it does NOT mess that topic at all.

It's a momentary bug but the problem happens with EVERY new topic published.

After all we only have to return to the page of the forum where the topic is and refresh it: voilá! the new topic is there, perfect.

It's not a huge problem but it's annoying because some people don't have enough patience to understand the little bug.

What can I do to solve this problem?

Thanks in advance for any good idea.

Note: My WordPress is in the 5.3.2 version.

I've made a new test using an installation of a WampServer in my PC.

In localhost I've run a fresh version of WordPress with new database and a copy of my current theme (with child theme) and current plugins.

When creating a new topic in the forum, the error ocurred again but with clear debug informations.

The problem is in a piece of code I've put in the file 'functions.php' as you can see below:

/**************************************************************************/

/* Extra function to create automatic subscriptions in the forum. I mean, an 'opt-out' option. */

function auto_subscribe($postID, $topicID) {AsgarosForumNotifications::subscribeTopic();
}
add_action('asgarosforum_after_add_topic_submit', 'auto_subscribe', 10, 2);

/**************************************************************************/

This code above was given to me by the Asgaros Forum editor when I asked him for a way to create automatic auto-subscriptions.

Is there a way to fix it?

*Deleting the code solves the problem but what about the automatic subscriptions? What can I do to have only 'opt-out' option on creating new topics?

Thanks!

Hi @asgaros,

I've found a solution and you don't need to answer me about that problem.

Our forum is private in a hidden page protected by password.

We use it to exchange information about new products and projects with regular customers and business partners.

They love this kind of use of the forum and they highly praised the clean, spacious, easy to use + read aspect.  Thank you for that!   🙂

- - - -

My solution is quite simple: every new member is created ONLY by me and I subscribe him/her to all topics and replies "by default".

*Some people forget or are too lazy to subscribe to topics.   🙁

Later, if the person decides unsubscribing something it's on his/her own.

Best!

Hi @eduardo

There was a small code-change in one of the last updates which requires a small update to this code. Please use the following one:

function auto_subscribe($post_id, $topic_id, $subject, $content, $link, $author_id) {
    global $asgarosforum;

    $asgarosforum->notifications->subscribe_topic($topic_id);
}
add_action('asgarosforum_after_add_topic_submit', 'auto_subscribe', 10, 6);

 

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

Thank you @asgaros,

Now it's working perfectly!