froger-me / wp-remote-users-sync

Synchronise users across WordPress websites
GNU General Public License v3.0
71 stars 34 forks source link

Issue with update 1.2.13 #74

Closed QuQuue closed 1 year ago

QuQuue commented 1 year ago

Thank you for a great plugin. However, after updating the plugin to latest version, am no longer able to sync both ways. Can sync from site A to B, not from B to A. Green ticks on site A, Red x on site B. Error appears to be isolated to plugin update only. Error message: 2023-08-19 07:10:20 - Alert - Error contacting the remote site: an undefined error occured. Please make sure the address is correct and try again. On the remote site, please make sure the plugin is activated and that the permalinks are up to date by visiting the permalinks settings page. 2023-08-19 07:10:20 - Info - Response data received from the remote site: Array ( [0] => Array ( [headers] => Array ( )

        [response_code] => 
        [response_message] => 
        [body] => 
    )
QuQuue commented 1 year ago

So, figured the issue is related to changing the wp_remote_post to wp_safe_remote_post, and found adding this snippet to the site not accepting the URL as safe worked. Not sure if this actually is a safe option, but seems to be working for now - both sites on same server btw (added to functions.php)

add_filter( 'http_request_host_is_external', 'wplr_http_request_host_is_external' ); function wplr_http_request_host_is_external(){ return true; }

Thanks to another github con tributor

froger-me commented 1 year ago

Please have a look at the source code of wp_safe_remote_post and test with your URLs to figure out why they don't get accepted. Moreoever, test for the URL in your filter if you need to use a URL WordPress does not consider safe, but DO NOT return true for all unsafe URLs - this is dangerous.