New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate whether Facebook connects from WordPress subdomain #255

Closed
kevinwhoffman opened this Issue Sep 10, 2018 · 3 comments

Comments

Projects
None yet
1 participant
@kevinwhoffman
Collaborator

kevinwhoffman commented Sep 10, 2018

A user has two different sites on the same server. One connects to Facebook fine, the other does not. The only noticeable difference is that one site is installed on a subdomain.

https://secure.helpscout.net/conversation/633528184/22854?folderId=2120007

Acceptance Criteria

  • Facebook is confirmed to connect from a WordPress site installed on a subdomain.
@kevinwhoffman

This comment has been minimized.

Show comment
Hide comment
@kevinwhoffman

kevinwhoffman Sep 10, 2018

Collaborator

Testing on the customer's subdirectory installation, I found that $_POST['wpbr_facebook_user_token'] is not present after the redirect back to the plugin Settings page. Since the user token is not available, it is not saved and neither are the pages. I'm investigating why that's happening.

Collaborator

kevinwhoffman commented Sep 10, 2018

Testing on the customer's subdirectory installation, I found that $_POST['wpbr_facebook_user_token'] is not present after the redirect back to the plugin Settings page. Since the user token is not available, it is not saved and neither are the pages. I'm investigating why that's happening.

@kevinwhoffman

This comment has been minimized.

Show comment
Hide comment
@kevinwhoffman

kevinwhoffman Sep 10, 2018

Collaborator

The cause of this issue is related to the redirect URL that is passed to the Connect to Facebook button. It looks like admin_url() is returning a URL with http:// when it should be https://.

This means after the Facebook connection occurs on WPBR website, it is redirected back to the plugin Settings URL containing http:// which causes another redirect to the plugin Settings URL with https://. It is during that final redirect where the necessary $_POST data is lost.

We need to figure out how admin_url() could return http:// for a site that is clearly https:// with correct siteurl and home options in the database.

Here is the line where the redirect URL is generated:
https://github.com/WordImpress/wp-business-reviews/blob/develop/views/field/partials/types/facebook-pages.php#L48-L52

Collaborator

kevinwhoffman commented Sep 10, 2018

The cause of this issue is related to the redirect URL that is passed to the Connect to Facebook button. It looks like admin_url() is returning a URL with http:// when it should be https://.

This means after the Facebook connection occurs on WPBR website, it is redirected back to the plugin Settings URL containing http:// which causes another redirect to the plugin Settings URL with https://. It is during that final redirect where the necessary $_POST data is lost.

We need to figure out how admin_url() could return http:// for a site that is clearly https:// with correct siteurl and home options in the database.

Here is the line where the redirect URL is generated:
https://github.com/WordImpress/wp-business-reviews/blob/develop/views/field/partials/types/facebook-pages.php#L48-L52

@kevinwhoffman

This comment has been minimized.

Show comment
Hide comment
@kevinwhoffman

kevinwhoffman Sep 10, 2018

Collaborator

WordPress being on a subdomain was a total coincidence and did not affect the solution.

It turns out the user had constants set in wp-config.php that used http instead of https. This was causing an extra redirect upon return to the plugin, which caused $_POST data to be lost.

Example of wrong constants:

define('WP_HOME','http://domain.com/blog/');
define('WP_SITEURL','http://domain.com/blog/');

Changing them to use https should resolve the issue:

define('WP_HOME','https://domain.com/blog/');
define('WP_SITEURL','https://domain.com/blog/');

Please keep this in mind for future issues regarding Facebook connection issues.

Collaborator

kevinwhoffman commented Sep 10, 2018

WordPress being on a subdomain was a total coincidence and did not affect the solution.

It turns out the user had constants set in wp-config.php that used http instead of https. This was causing an extra redirect upon return to the plugin, which caused $_POST data to be lost.

Example of wrong constants:

define('WP_HOME','http://domain.com/blog/');
define('WP_SITEURL','http://domain.com/blog/');

Changing them to use https should resolve the issue:

define('WP_HOME','https://domain.com/blog/');
define('WP_SITEURL','https://domain.com/blog/');

Please keep this in mind for future issues regarding Facebook connection issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment