still cant get it to work with wordpress.com
-
when i click send it does not send
when i allow url to be used i get a different issue (WP Plugin SAC: Name and comment required. Please complete all required fields and try again.)
the website where is use it is https://stevencokerfanclub.com/chat/
-
I inspected the code using browser code inspector. It shows the following error:
Failed to load resource: the server responded with a status of 500 () sac.php:1
So the required file
sac.php
is not getting loaded for some reason. That most likely is the reason why the plugin is not working on your site.how do i fix this
I don’t know tbh, I develop for www.ads-software.com (self-hosted). The plugin should work fine on WordPress.com, but you would need to contact them if something is not working. Also make sure you’re running the latest version of SAC, 20220720.
i talked to wp support and they found these errors
[21-Aug-2022 20:39:22 UTC] PHP Warning: Undefined array key "HTTP_HOST" in /srv/htdocs/wp-content/plugins/simple-ajax-chat/simple-ajax-chat-form.php on line 7 [21-Aug-2022 20:39:14 UTC] PHP Warning: session_set_cookie_params(): Session cookie parameters cannot be changed after headers have already been sent in /srv/htdocs/wp-content/plugins/simple-ajax-chat/simple-ajax-chat-form.php on line 9 [21-Aug-2022 20:39:14 UTC] PHP Warning: session_start(): Session cannot be started after headers have already been sent in /srv/htdocs/wp-content/plugins/simple-ajax-chat/simple-ajax-chat-form.php on line 11
Thanks for the infos.
Those PHP warnings should be resolved once
sac.php
is loaded on the page. That’s the issue here:sac.php
is not getting loaded. As explained in previous comment, your page shows the following error:Failed to load resource: the server responded with a status of 500 () sac.php:1
Howdy, @specialk
In this case, the issue is with how the plugin is attempting to load wp-config.php and wp-load.php
Specifically, within
/wp-content/plugins/simple-ajax-chat/resources/sac.php
require(dirname(dirname(dirname(dirname(dirname(__FILE__))))) .'/wp-config.php'); require(ABSPATH .'/wp-load.php');
There’s an incorrect assumption that wp-settings will be within the same directory as wp-config and the plugin is incorrectly bypassing the normal WP load.
As not all hosting environments are the same, and some symlink and store root files elsewhere, this can result in the following error.
PHP Fatal error: Uncaught Error: Failed opening required '/srv/htdocs/wp-settings.php' (include_path='/:.') in /srv/htdocs/wp-config.php:83 Stack trace: #0 /srv/htdocs/wp-content/plugins/simple-ajax-chat/resources/sac.php(10): require() #1 {main} thrown in /srv/htdocs/wp-config.php on line 83
Ideally, the plugin would not be requiring wp-config and wp-load in this way
* https://codex.www.ads-software.com/AJAX_in_Plugins
* https://ottopress.com/2010/dont-include-wp-load-please/
* https://wordpress.stackexchange.com/questions/159347/best-way-to-include-wp-config-phpIf you would like to get a test site in an environment where this code won’t work, feel free to reach to me via https://wordpress.com/support/developers/
- This reply was modified 2 years, 3 months ago by Joshua Goode.
- This reply was modified 2 years, 3 months ago by Joshua Goode.
- This reply was modified 2 years, 3 months ago by Joshua Goode.
Hey thanks for the infos, @verygoode, very much appreciated. I guess I am confused by what I am hearing from the WordPress.com team regarding wp-config. In contrast to what you are saying above, I received the following information from “Thom” at WP.com:
==
Hey there, Jeff!
My name is Thom and I’m one of the Happiness Engineers here at WordPress.com.
We recently received a support request from a user who was looking to use your Simple Ajax Chat plugin on the WordPress.com platform but was coming across some errors. We have extensively tested the issues and we were able to replicate the issue on some test sites. Please see our findings below.
wp-config.php and wp-load.php
We see that in some of your files you are using
require(dirname(dirname(dirname(dirname(__FILE__)))) .'/wp-config.php');
. The only reason that I can see that you are calling this is so thatABSPATH
is set for the next call torequire(ABSPATH .'/wp-load.php');
It is not recommended to access
wp-config.php
directly and as such it may cause issues if this is the case. In this instance, I believe it is one of the reasons that the user was getting the 500 error regardingwp-settings.php
.It’s worth noting that
wp-load.php
not only setsABSPATH
itself but also runswp-config.php
too so our advice here would be to replace the call towp-config.php
entirely and just userequire(dirname(dirname(dirname(dirname(__FILE__)))) .'/wp-load.php');
to ensure that the WordPress environment loads correctly.==
So @verygoode based on that, the load method was changed in a recent update of SAC. Now you’re telling me that the information from Thom is incorrect?
- This reply was modified 2 years, 3 months ago by Jeff Starr.
- This reply was modified 2 years, 3 months ago by Jeff Starr.
Thom was correct in his warning about not loading wp-config.php in this way — which the plugin still does and is contributing here.
As for wp-load.php, that shouldn’t be included. The path recommended might be better but wp-load.php shouldn’t be used this way and can result in issues.
I also do not see any recent changes to this within sac.php, unless changes were made elsewhere.
https://plugins.trac.www.ads-software.com/browser/simple-ajax-chat/tags/20220720/resources/sac.php
https://plugins.trac.www.ads-software.com/browser/simple-ajax-chat/tags/20210714/resources/sac.php
“As for wp-load.php, that shouldn’t be included. The path recommended might be better but wp-load.php shouldn’t be used this way and can result in issues.”
So am I to understand that there are people working for WordPress.com that are giving incorrect advice? This is very confusing and frustrating.
“I also do not see any recent changes to this within sac.php, unless changes were made elsewhere.”
The changes were made elsewhere. I forgot to update
sac.php
. But now not sure, it may be that SAC simply is not compatible with WordPress.com, despite what I had been hearing from Thom (who is great btw).So am I to understand that there are people working for WordPress.com that are giving incorrect advice? This is very confusing and frustrating.
I’m not sure if it was incorrect but it didn’t mention best practices. Including wp-load.php is generally not good practice and something we should have highlighted.
Thom offered an alternative to get things working in many environments similar to WordPress.com’s without removing the require for wp-load.php. But, ideally, wp-load.php wouldn’t be included.
https://ottopress.com/2010/dont-include-wp-load-please/ covers this a bit better than I can.
Thom was also correct in his notes regarding wp-config.php, which is the primary cause of the 500s. Generally, wp-config.php should not be included in this way.
Applying Thom’s notes, removing the requirement for wp-config.php and altering the wp-load.php path to use what he shared would get SAC working on hosts similar to WordPress.com.
WordPress.com is not the only host that has a setup that SAC would conflict with. Some have entirely different setups that would lead to the same issue.
- This reply was modified 2 years, 3 months ago by Joshua Goode.
Thanks for all the infos. I will look into possible solutions or workarounds for WordPress.com and similar. For now, I suppose SAC (free version) is not compatible with WordPress.com. The pro version is completely rewritten btw, and uses WP Ajax instead of including wp-config as in the free version. Thanks again.
Sounds good @specialk and thanks for the chat!
The pro version is completely rewritten btw, and uses WP Ajax instead of including wp-config as in the free version. Thanks again.
That’s great to hear!
- The topic ‘still cant get it to work with wordpress.com’ is closed to new replies.