Skip Navigation

[Resolved] Related posts not being populated consistently

This support ticket is created 2 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Author
Posts
#2284331
Screenshot 2022-02-05 at 11.27.46.png
Screenshot 2022-02-05 at 11.26.54.png

Hi Support

When a user views a post of type Job Ad or Nanny Ad on our site, they are able to write a message to the post author using Toolset messaging, depending on what role they have. Toolset provided some custom code for us to get this working. However recently we have noticed that the related Ad is not being populated consistently. Sometimes it works, others not, although we have not changed anything in that area. I can see that the Relationships still exist between the post types Job Ad and Messages and Nanny Ad and Messages, but cannot understand why this doesn't work every time, so the only thing I can think of is some plugin update or WordPress 5.9 update may have broken some code or logic.

There's 2 custom code snippets related to messaging for your reference:
- func-connect-hidden-ids-messages
- toolset-messaging-code-snippets

To reproduce the issue easily with users with roles allowed to message each other, please use the following two test logins:
{login info removed}

Steps to reproduce:
1) Log in as Nanny. You should land on the Find a Job page.
2) Click the Job Ad from "Müller family" and there you can write a message and click Send Message.
3) On the menu, click the Messages > Outbox. The Related Ad should be visible on the message.
4) Next log in as Family: Click Messages > Inbox. You should see the Message just sent from Siobhan Smith and its Related Ad.
5) Open the message by clicking on Siobhan Smith's name and reply to the message.
6) You should see the message you just sent from Thomas in Siobhan's inbox.

You could also repeat the test the other way round, from Find a Native Nanny, logged in as Thomas and responding to the Nanny Ad from Siobhan.

In all cases, in the Inbox and Outbox, the Related Ad should be populated against the Message, but as you can see it is not always being populated.

We would appreciate your assistance in getting this working again reliably every time.

Kind regards
Simon

#2285583

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Simon,

Thank you for contacting us and I'd be happy to assist.

I've used the access details for the test Nanny and Family users and noticed that the related Ad posts are populated correctly. I've checked the sending and receiving messages through both users, which are available in the inbox and outbox of those users.

The two code snippets that you mentioned also look straightforward and theoretically, should work every time.

Have you checked the server's error log for any errors or warnings? If something fails intermittently, mostly it is due to some cached content at the server or CDN level ( if in use ).

I'll recommend temporarily enabling the WordPress error logging and then performing some tests with back and forth messaging, to see if any errors or warnings are recorded and if any pattern can be established for failed connections.
( ref: https://wordpress.org/support/article/debugging-in-wordpress/ )

regards,
Waqar

#2286269

Hi Waqar

Thanks for the update.

It seems there are many "caches" in WordPress. Exactly which cache are you referring to? We use WP Rocket on the site, but don't use a CDN.

Kind regards
Simon

#2286749

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for writing back.

If your website is not using a CDN, that leaves the cache investigation to these two levels:

1. Server:
Please make sure that your hosting server is not applying maintaining server-level content or object cache on its own. Different hosting services can offer these optimization services under different names and most of the time, they're enabled, by default.

2. WordPress:
WordPress level cache is managed by the optimization plugin that you're using, which in this particular case is "WP Rocket".

If you constantly come across issues where related posts (or any other changes for that matter), don't show up immediately on the front-end, but, do appear after some time without any manual intervention, most likely, your optimization plugin is set up too aggressively. In that case, you should consult the WP Rocket plugin's official support and documentation to make the optimization settings less aggressive, especially for the logged-in users.

Coming back to the issue at hand, the form set up and the associated code snippets seem to be working correctly at the moment. If you see some message entries without the related posts/ads again, please be sure to check the error log and let us know.

#2288163

HI Waqar

1) I checked our hoster settings. The only cache related setting I could find was OPCache and that was set to OFF.

2) I clear the WP Rocket cache regularly during dev work to ensure that the "latest" version is being shown in the browser. Surely the Related Ad ID should just be an ID that gets stored in a record on the database when the Message is created? It would seem strange to me that the ID should not be available at the moment when a user clicks Send Message.

As with all intermittent problems, they are of course difficult to troubleshoot, as we don't know when they are gonna strike 😅😜

Kind regards
Simon

#2288573

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thanks for the update and it's good that these two points have been ticked off from the list.

When troubleshooting for the unusual and intermittent issues, one has to make sure that all bases are covered.

I'll recommend continuing testing sending and receiving these messages with error logging turned on. This way, if the issue appears again, you'll be sure to catch something in the server's error log. It would be a good idea to test with a couple of different tests user accounts and also try sending messages simultaneously, to see if that has any effect.

#2288895

HI Waqar

We tested our messaging system and we are happy that it's working the way we need it to now.

Thanks for your help!

Kind regards
Simon

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.