WARNING: THIS IS AN OLD POST - IT STILL WORKS, BUT I’VE REMOVED THIS PLUGIN FROM THIS BLOG. I’VE LEFT IT UP FOR REFERENCE SINCE WE DISCUSS IT IN THE NEWSLETTER! There is now a facebook programming section on this blog. –> Facebook API Tutorials and Programming.
It seems that everyone is having an easy time installing the Sociable Facebook Plugin, but are having a horrible difficult time getting their WordPress installations to hide content unless they have liked your page and logged into facebook.
I spent several hours pouring over all I could find about the facebook API, the new open graph stuff, etc… and trying to hide stuff on my site unless the viewer was logged into facebook just wasn’t working well. I could hide content but I sure couldn’t show a lot of content and it broke the moment I added any html code.
I did figure things out and I’ll show you below………. but you are going to have to leave a comment by logging into facebook for me to tell you about it
Do this:
Login with facebook below.
Give this website access to some of your facebook public info (normal all apps do it).
Control+Refresh the page… or click on any other post and then come back to this one
Do all that and you will see the content (and how it’s done) for this post.
You made it
Let’s talk about what’s happening with this plugin first. When you log into facebook and come back the sociable plugin actually gets some data from facebook and creates (and logs in) a user that is you. Basically you are a subscriber inside wordpress now.
The better news is that I’m now able to use fun functions inside wordpress to only show content to you if you are logged in.
You also need to install the exec php plugin for this to work. Install and activate it – then you can include php code inside your posts.
The code is going to look like this:
<?php if (is_user_logged_in() ) { //only logged in WP user can see this ?>
<div><p>I’m the secret words, html, images, etc… that you only want logged in people to see!</p></div>
<?php } ?>
Might be easier for those of you who aren’t skilled with the html to just put all the content (what everyone sees and the private stuff) on your post in design view – then move over to html view and add this above the content you want to hide:
<?php if (is_user_logged_in() ) { //only logged in WP user can see this ?>
<div><p>
and this below the content you want to hide:
</div>
<?php } ?>
That’s it kids – nothing to complicated here. I even set it up so you can use ‘, and ” inside your content and not have to escape it.
WARNING: THIS IS AN OLD POST - IT STILL WORKS, BUT I’VE REMOVED THIS PLUGIN FROM THIS BLOG. I’VE LEFT IT UP FOR REFERENCE SINCE WE DISCUSS IT IN THE NEWSLETTER!
12 Responses to Facebook Force Log in – gather data – get liked!
Leave a Reply Cancel reply
Codebank Latest Releases
Codebank Recently released: Location Generator Magic Keyword Plugin Magic Rss Linker 4 new tutorialsCategories
- 30 Day Website Network
- Black Hat Experiments
- Changing Affiliate World
- CodeBank
- Contests
- Digest
- Facebook Programming
- Featured Articles
- Features
- Internet Marketing Tips
- Network Building
- Network Progress Report
- Newbie Corner
- Online Tools
- Overview
- Rambling
- Rss Marketing
- Tutorials
- Uncategorized
- What Are We Going To Do Today?
Rss Notifications




[...] Force Facebook Login To Hide Content [...]
I should note that you can’t force people to “like” your page this way. But you could ask them to login with facebook and like it – then refresh the page.
90 percent of the people would do it.
I’ll try out the api again in a couple weeks – seems to be a problem stopping it from working properly at the moment.
Interesting, I click “Login with Facebook” and it refreshes the page, but still shows “Login” and requires that I enter my name and email to leave a comment. Weird.
Oh, but after I left the comment, it shows me logged in through FB. Might want to check into that Ed.
It sure isn’t perfect. That’s for sure. This is the best way you have of doing it with WP for now though.
The best bet is to make a real application that uses the oauth system and totally ignore WP altogther.
This is a lot faster if it does have a few hiccups.
good stuff
[...] with facebook</p></li> </ul> Of course you do need the plugin we talked about here or to have them register with your blog through WP’s normal log in [...]
Nice.
Won’t work with regular readers though, if they’re already registered and logged in.
Not working for me
not working for me either
i dont get it. i’ve already logged in with facebook but the login button is still there
Doesn’T work for me…where’s the info???