I'm using this code below as a plugin. It seems to work but sometimes it seems to be stuck in a loop. When I have this plugin running my facebook social sharing doesn't grab the correct page and content for a share post. I turn off the plugin and facebook share works great. What am I doing wrong?

1 Answer
1

Facebook grabs your site's content by making an http request just like any other visitor, you're forwarding any attempts to scrape your pages to the login page.

You could try checking for the Facebook user agent to let their crawlers through, but anyone could masquerade as the Facebook bot and browse your site without logging in by simply changing their browser's user agent.

thanks.. but my real issue here is to find the correct/best way to force users to login to the standard wordpress login or any url I may want. can anyone suggest a way or help me fix this endless loop which ultimately crashes.
–
Thom EdwardMar 6 '13 at 2:18

You could try not using Facebook and other sharing code on pages that users have to log in to see.
–
OttoMar 6 '13 at 5:40

again, I would rather forget about facebook right now and fix this endless loop... any suggestions on this function? is there a better one that doesn't loop out?
–
Thom EdwardMar 6 '13 at 8:18

@ThomEdward what endless loop problem? Describe the steps to reproduce this issue. Your code works fine for me on a vanilla WP install and twentytwelve theme.
–
MiloMar 6 '13 at 15:15