O'Reilly logo

Facebook Cookbook by Jay Goldman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Display Content to Network Members

Problem

How do I display content only to members of a specific network?

Solution

Use the fb:is-in-network tag and specify the network and uids. The simplest form is:

<fb:is-in-network network="12345" uid="12345">Private
 content goes here</fb:is-in-network>

Discussion

Although this tag doesn’t start with the word “if”, you can still use it in combination with the fb:else tag to display alternate content to people who aren’t in the network:

<fb:is-in-network network="12345" uid="loggedinuser">
    Private content goes here
    <fb:else>
        Sorry! You're not in <fb:networklink nid="12345"/>.
    </fb:else>
</fb:is-in-network>

Note that the tag uses network="12345" and not nid="12345" as you might expect.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required