Archive for the ‘easy solution’ tag
Google+ Hangouts On Air: What Marketers Need to Know
What if your business could do live video broadcasts to unlimited viewers–instantly and for free?
Want to share your screen and slides, no problem. Need it to be super easy?
This is all possible with using the free Google+ Hangouts On Air!
You’ve probably already heard about Google+ Hangouts, which allow you to video chat with up to 9 different people at once.
And you may have heard of Google+ Hangouts On Air, which lets you broadcast to an unlimited audience. But this cool feature was previously only available to a select number of bigger businesses.
http://www.youtube.com/watch?v=3pmSWh2BQco
Watch this quick video to see it in action…
Well, Google+ recently announced the rollout of Hangouts On Air to everyone worldwide. This is great news for marketers looking for a free and easy solution to reach people via videos.
So let’s talk about everything you need to know about using Google+ Hangouts On Air for your business.
First, a brief introduction…
Google+ Hangouts On Air
Hangouts On Air allow you to publicly broadcast your Hangouts on YouTube and your Google+ stream for anyone to watch.
Yep, it’s like having access to your own live video show on the web—viewable to anyone in the world.
In another recent Google+ update, Google+ added a Hangout icon in the left navigation ribbon to promote all the public Hangouts.
Hangout link on left-hand navigation ribbon in Google+.
This Hangout link has given a lot more visibility to public video chats—and it’s now much easier to find and network with others visually on air.
What Businesses Can Do With Google+ Hangouts On Air
Here’s a closer look at what you can do with Hangouts On Air.
Broadcast Your Video on Google+ and YouTube
When broadcasting, your video will stream live on your YouTube account and on your Google+ stream. This means you can share your YouTube URL with anyone who wants to watch your broadcast live.
In the video below, Daria Musk Concert Hangout On Air from The Living Room in NYC:
http://www.youtube.com/watch?v=xgIvOSyZfAU
Live-Stream Your Hangout on Any Website
While in your Hangout, you can grab the YouTube video embed code and paste it into your blog or website to get more viewers and reach.
Click on the Embed link to get the YouTube code that you can paste into a blog post or website.
Incorporate Google+ Apps
Right now, you can use a number of applications like Google Docs, SlideShare and Cacoo to help you collaborate or present your ideas in video. This gives you the same functionality of hosting your own webinar at no cost.
Here’s a peek at some of the apps you have access to at the moment:
Google+ Hangouts applications.
Cacoo allows you to collaborate on a drawing with others in your Hangout. This app provides tons of templates to choose from (e.g., flowcharts, Venn diagrams, sitemaps, database designs, etc.).
Example of a Cacoo app in Google+ Hangouts.
SlideShare allows you to view and use the presentations in SlideShare. This is just another reason to store and share your presentations in SlideShare.
Example of the SlideShare app in Google+ Hangouts.
Scoot & Doodle allows everyone in your Hangout to draw together. You can play games, doodle or draw on your face. It’ll be fun to see how this app evolves over time.
Example of Scoot & Doodle app in Google+ Hangouts.
Chat on Sidebar
Simply click on the Chat button on the top left to chat with others during your Hangout.
If you’re doing a presentation, invite others to leave questions or comments in the sidebar as you’re talking or presenting a slide.
Chat bar in a Google+ Hangout.
Screen Share
To share different parts of your screen, simply click Screen Share to select which window you want to show everyone else.
This is helpful if you want to talk about a website, application, program or anything else on your desktop.
After clicking Screen Share, you can select which window you’d like to share with everyone.
Edit Your Hangout When Complete
After your Hangout On Air, you can edit the video in your YouTube account (connected to your Google+ account).
Simply go to your Video Manager page and click on the Video Editor link on top of the page.
Video Editor in YouTube.
Share Your Recorded Hangout
Once you’re happy with your video, you can then share it just like any other YouTube video.
Click on the Share button below your YouTube video to get your link or embed code.
How to Start Your First Hangout On Air
Now let’s talk about how to start your first Hangout On Air…
#1: Log into Google+ and Click on the Hangout Button
Simply log into your Google+ account and click on the Hangout button on the right side of your stream.
Hangout button is located to the right of your homepage stream in Google+.
#2: Name Your Hangout and Invite People
Invite a circle of people to join you in your Hangout. If you invite fewer than 25 people, they will receive an instant message with a link to join. However, if you invite more than 25 people at a given time, the Hangout invite will just be shown in their stream (which might not get seen).
Add names or circles of people you’d like to invite.
You can also invite people to join you by phone if they’re not available online.
To invite someone to your Hangout by phone, simply type in a phone number to call.
#3: Check “Enable Hangouts On Air”
After naming your Hangout and clicking on the Enable Hangouts On Air box, you’ll get a pop-up informing you that the hangout session will be streamed on your YouTube channel and on your Google+ stream.
The first step in starting a Hangout On Air is to click on the Enable Hangouts On Air box.
Once you click on the blue Okay, Got It! button, you’ll need to agree to Google’s terms of service.
#4: Agree to Google’s Terms
Make sure you read through the terms of service—especially if you’re using this on behalf of your company. You only need to agree to the terms during your first Hangout. You may want to consider having your company’s legal team review this contract before moving forward.
Anyone you invite into a Hangout will need to agree to Google+ terms of service.
Once you click that you agree and click Continue, you’ll start your first Hangout session. You can then wait for others to join your Hangout or start broadcasting live without them.
Anyone else you invite to join your Hangout will also receive a note to inform them the Hangout will be live-streamed on YouTube.
Anyone else you invite to join your Hangout will also receive a note to inform them the Hangout will be live-streamed on YouTube.
#5: Press Start Broadcast to Video Chat On Air
To start broadcasting your Hangout, click on the red Start Broadcast button.
The Start Broadcast button is located on the top right of your screen.
After pressing the red Start Broadcast button, you’ll get one more message informing you that the broadcast will be public.
#6: Broadcasting Publicly
This is your last message telling you that the video content will be public. Google really wants to make sure you know what’s happening next.
This is your last announcement that you are about to broadcast your Hangout publicly on YouTube.
After clicking OK, the red button will give you a 10-second countdown before going live. Take a deep breath and smile.
What to Do After Your Hangout
After you’ve finished your Hangout, it could take up to an hour before the video appears in your YouTube account. Don’t worry if you don’t see it right away because it will upload very soon.
When the video is ready, you’ll find it appearing in your YouTube Video Manager page where you can then place it into a playlist, start sharing or edit.
Edit Your Hangout Video
Simply go to your Video Manager page and click on the Video Editor link on top of the page if you want to:
- Add approved music or sound effects
- Trim or customize clips
- Integrate more video from other video clips you’ve uploaded
Click on the Video Editor link in your top navigation to launch the video editing application.
Share Your Recorded Hangout
Once you’re happy with your video, you can then share it just like any other YouTube video.
- Share your YouTube URL with anyone
- Embed the YouTube code on your website
Click on the Share button below your YouTube video to get your link or embed code.
Submit Your Favorite Hangouts On Air to Google+
Google+ is inviting you to share your favorite broadcasts with them. We’re not sure what Google will do with them, but it might be a fun way to promote your business if they decide to use it in some promotion.
How to Record Longer Hangout Sessions
If you’re familiar with posting video on YouTube, you know that you need permission to post videos longer than 15 minutes. Since many Hangouts might last longer than 15 minutes, you should verify your account with YouTube so your recorded video doesn’t get cut.
Here’s how to enable longer Hangout recordings:
Once logged into YouTube, go to your Upload page and click on Increase Your Limit. You’ll need to verify your account by submitting your mobile phone number.
YouTube account verification to increase your video upload limit.
Google will then text you a code that you need to type in to verify your account.
YouTube verification step 2.
And then you’ll receive the announcement that you can upload video longer than 15 minutes.
YouTube Verification Complete announcement.
That’s all you need to do to get a verified account, which you should do if you want to avoid getting your Hangouts cut at the 15-minute mark.
Google+ Hangout On Air Tips
Here are a few other tips you should know before starting your first Hangout (especially if you’re using it on behalf of your company):
Remember the YouTube Terms of Service and Copyright
You are responsible for the video content (and what others do within the Hangout). If someone acts inappropriately or plays copyrighted audio or video in the background, it can count against your personal account. Remember to follow YouTube’s terms of service and their community guidelines during Hangouts On Air.
Consider speaking with an attorney before engaging in Hangouts on behalf of your company.
Block Inappropriate People and Tell Others
If you’re hosting a Hangout On Air, you can block anyone you think is inappropriate. But just because you’ve blocked them from appearing in your Hangout doesn’t mean that others in the Hangout can’t still see or hear them.
So if you block someone, ask the rest of the group in your Hangout to block them, too.
Unable to Stream Live Hangout From Your Company YouTube Account
There isn’t a way to associate your Google+ page Hangout with your company YouTube page at this time.
All Google+ Hangouts On Air are automatically associated with the page administrator’s YouTube account.
You’ll need to download the video from your personal account and upload it into your company’s account if that’s where it belongs.
Mute Your Audio if You Want to Watch Your Broadcast Live to Avoid Hearing an Echo
While hosting your Hangout, you can go to your Google+ profile to watch the video streaming. Just make sure to mute the audio so you don’t hear an echo.
Use a Unique Name for Your Hangout
It’s important to choose a unique name for your Hangout because others might unintentionally join simply because they typed your Hangout name when creating their own. Those people will automatically join your Hangout. So make sure to choose a unique name.
Play in Hangouts by Yourself First
Take some time to get a feel for what it’s like in a Hangout by starting one with just yourself. Play with apps. Learn the interface. Switch back and forth between video of you and your screen.
Get comfortable with it before launching your first real Hangout for business.
Practical Ways to Use Hangouts On Air for Business
There are countless ways you can use Google+ Hangouts On Air for business. Here are just a few:
Customer Service Live Q&A
Do your customers or clients ask you the same types of questions? Why not host a weekly Hangout On Air to address common questions live? Promote the live video series and invite people to tweet questions to you during your presentation.
Post the video on your website for those who missed it.
Here is Obama answering questions:
http://www.youtube.com/watch?v=eeTj5qMGTAI
Live Expert Interviews
A great way to build an audience is to conduct thought-leadership interviews. Invite an expert to hang out with you on a particular day, and promote it to your clients, customers and/or target market. You can then embed the YouTube code on your blog or website so that everyone knows where to go to watch it. You could even host a panel discussion with up to 9 different experts to present on an important topic.
Here’s a panel discussion on education:
http://www.youtube.com/watch?v=LtmdiPUGGe8
Khan Academy founder Sal Khan and Stanford professors Peter Norvig and Sebastian Thrun discuss the future of technology in education. They are taking questions live on Google+.
Vlogging
If you’ve ever wanted to start a regularly scheduled vlog for your company, you don’t have any excuses anymore. Now you have everything you need to host your own show. Set a time each week to put on a live video show to talk about your business or topics important to your industry.
Check out Trey Ratcliff’s Google+ photography show:
http://www.youtube.com/watch?v=YVVWwOPC5AY
And check out this great blog post for more ideas on using Hangouts for business.
What do you think? There are so many possibilities for using Google+ Hangouts On Air for business. I hope you find some of these tips helpful. Let me know how you think you’ll be using Hangouts On Air, or any other comments or questions you have. Leave your comments in the box below.
Speed Up Dropbox’s File Syncing with a Simple Tweak [Dropbox]
File-syncing service Dropbox is magical—even if it’s got a fresh new competitor. It syncs files between your computers and the web hassle-free… except when the file’s taking too long to sync. If you’ve ever stared impatiently at Dropbox, waiting for a file to sync, there’s likely an easy solution. More »
Five For Friday: April 20, 2012
In a new feature that I hope to keep up each Friday, I’ll take a look back at the week and summarize five stories I found newsworthy, noteworthy, insightful, interesting, or just plain fun to read. We’ll do this to keep ourselves on our game, and to help keep you on yours. Oh, and to save you the effort of having to filter through the 5,000 unread items in your Google Reader.
Let’s call this regular feature Five For Friday. And here are my picks for the week ending Friday, April 20, 2012.
The Jig Is Up: Time to Get Past Facebook and Invent a New Future
We have reached the tipping point in tech advancement–but what do we do now? The article is an interesting rundown of major breakthroughs in the past decades and how they’ve altered our lives. The focus is on why we’ve stopped innovating with all these great toys we have at our disposal, and while Atlantic contributor Alexis Madrigal sheds necessary light on the problems, a clear solution never really crops up here. The closest thing we get is an approximation of “future-shock.”
The Future of Media = Many Small Pieces, Loosely Joined
Matthew Ingram’s GigaOM piece that inspired our post earlier this week. No news here: traditional media’s ad revenue streams are drying up–the print industry has been watching that leak for years, wondering and hoping but not acting swiftly or aggressively enough. With insight, Ingram’s article focuses on the ways the media industry can perhaps turn this around, and it’s not about one big easy solution. While digital-native media has the upper-hand, traditional media should look to multiple (smaller) sources of digital revenue that have the potential to add up fast, such as custom publishing and e-books, as well as leveraging “in-sourced” skills and live events that are already a part of their business.
The Four Worst Innovation Assassins
It’s easy to claim a corporate culture that promotes innovation, yet it doesn’t seem to be a top concern for many companies. Even if you have a leader who seemingly champions the cause, writes innovation expert Scott Anthony, he or she may actually be the single greatest obstacle in innovation’s way. Collected in this short list are four of the leader personality types to watch out for, and a simple solution for promoting innovation in your organization.
Physical Media is Dead — Long Live the App
Om Malik on the decay of physical media, the rise of digital media and why apps are the “right metaphor” for the new world. Agreed, but how long before we’re going beyond apps into another type of “container”? This is a fast, rushed, shaky new world, as Malick mentions, and while apps are just starting to take a real, firm hold, it is unlikely they are our most satisfactory content-delivery model. But he brings up a great point near the end–if advertising agencies don’t already have a new approach for the new world, they’re going to need one if they don’t want to find themselves disrupted in the wake of broader media and marketing disruption.
It’s Not About Instagram — It’s About Mobile
The title says it all, but the point is worth discussing: Facebook needs to monetize their mobile app and mobile web presence, which they are not currently doing. If they continue on that path, their revenue and valuation will end up taking a serious hit. While on its surface Instagram is a photo sharing application, the more important reality is that that team built a wildly successful social experience that was mobile at its core. So Facebook’s Instagram deal really represents a serious push into mobile, and should be a signal to everyone else (if proof was needed) that having a solid mobile computing strategy and a clear plan for monetizing your mobile assets are the keys to the future of any media company (traditional, digital or social) and–for that matter–any brand that wants to maintain consumer relevance and engagement over time.
Google: One URL With Special Stylesheet Is Easy Mobile SEO
I love SEO topics where there is no solid firm answer and one of those areas is mobile SEO. Google has no clear guidelines on how you should set up your site properly to handle mobile users and mobile bots. They tell you to treat Googlebot mobile like you would mobile users but not exactly how to structure your site for it.
Do you use mobile URLs, do you use the same URL with a mobile template. Google says, you can do both. But which is better. This is where there is a split in the SEO industry on expert opinion. I think it depends but most of the time, for SEO purposes, use the same URL, with a special mobile template.
Google’s John Mueller said yesterday in a Google Webmaster Help that the easy solution is to go the one URL route with a special template. He is specifically replying to an issue with redirects for a mobile SEO strategy gone wrong. He wrote:
An easier solution, if you can do it, is to just serve smartphone and desktop users from the same URLs, using something like special stylesheets or CSS3 media-queries to optimize the content shown on smartphones. The advantage of that is that you don’t need special URLs, think about the crawling and indexing of them, nor would you need to consider how you’d redirect smartphone users.
John then links to an article from a year ago, which I personally think confuses things a bit more.
I really want a definitive answer from Google on mobile SEO best practices, but honestly, it is changing so rapidly, it might be too much to ask for.
Forum discussion at Google Webmaster Help.
Limiting The Visibility Of WordPress Posts Via Usernames
Controlling who is able to view a post is a simple task once the system is established. Limiting access to certain users has several applications, such as enabling a design studio to distribute artwork to its various clients, or enabling a small school to arrange for homework to be posted online using a cheap and easy solution.

The easiest method to get this system working is to make the recipients of the information “subscribers” (since they need not be able to post) and the distributors of information “authors” (since they should only be able to edit their own posts). This system eliminates several headaches for the webmaster by managing who has access to particular posts. The username would be used to identify who is allowed to view certain posts, since it is unique and, for the most part, constant.
The Basics
What Will You Need?
- WordPress 3.1 or later
- Members of various roles
- The ability to modify your theme’s files
- Basic knowledge of PHP and MySQL
What Is a Username?
In general, a username is a means by which to identify and verify a user. It is not the only way to identify a user, but remembering a username is easier for the person logging in than having to remember a random user ID. A username can be made unique to an individual, unlike a person’s name or email address (family members may share the same name, or even the same email address). This ease of use and uniqueness is why usernames are used on most websites that require people to sign up in order to access the website or certain of its features.
To WordPress, a username is means of identifying a user. Paired with a password, a username enables someone to access their profile and, depending on their permissions within WordPress, to access to the administrative pages of the website. A username can be used for many functions in the operation and management of a website, such as karma, prestige, user roles and expulsion.
A WordPress username is unique and impossible for the average user to change. Thus, the system is a potentially reliable means of identifying individuals. This reliability is important for a system in which a post must be visible to only a few people. The permissions of a post should not alter merely because someone has changed their name or email address.
![]()
The user page in a WordPress installation. Note that “Usernames cannot be changed.”
Setting Up The Back End
In order for an author to be able to set permissions for visibility, a method of selecting users must be set up on the post editing page. We could accomplish this by one of several methods, one of the easiest and most efficient of which is to create a meta box (or widget) in the post editing page that allows the author to add custom information, as required by a theme or plugin. This information enables us to tell the theme which members should have viewing rights to particular posts.
A Basic Custom Meta Box
Justin Tadlock’s article “How to Create Custom Post Meta Boxes in WordPress” explains how to create meta boxes, and we’ll reuse that code here.
Let’s assume we’re dealing with a website for a music school named “Smashing Magazine’s Fancy Flautists.” We will use the name smashing_flautist_access in the code for the back end to distinguish it from other custom functions. Justin’s code is a great starting point for this project, but it needs a little customization for our purpose. Place the following code in your theme’s functions.php, and modify the various labels according to your project.
/* Fire our meta box setup function on the post editor screen. */
add_action( 'load-post.php', 'smashing_post_meta_boxes_setup' );
add_action( 'load-post-new.php', 'smashing_post_meta_boxes_setup' );
/* Meta box setup function. */
function smashing_post_meta_boxes_setup() {
/* Add meta boxes on the 'add_meta_boxes' hook. */
add_action( 'add_meta_boxes', 'smashing_add_post_meta_boxes' );
/* Save post meta on the 'save_post' hook. */
add_action( 'save_post', 'smashing_flautist_access_save_meta', 10, 2 );
}
/* Create one or more meta boxes to be displayed on the post editor screen. */
function smashing_add_post_meta_boxes() {
add_meta_box(
'smashing-flautist-access', // Unique ID
esc_html__( 'Post Viewing Permission', 'smashing_flautist' ), // Title
'smashing_flautist_access_meta_box', // Callback function
'post', // Admin page (or post type)
'normal', // Context
'default' // Priority
);
}
/* Display the post meta box. */
function smashing_flautist_access_meta_box( $object, $box ) { ?>
<?php wp_nonce_field( basename( __FILE__ ), 'smashing_flautist_access_nonce' ); ?>
<p>
<label for="smashing-flautist-access"><?php _e( "Enter the username of the subscriber that you want to view this content.", 'smashing_flautist' ); ?></label>
<br />
<input class="widefat" type="text" name="smashing-flautist-access" id="smashing-flautist-access" value="<?php echo esc_attr( get_post_meta( $object->ID, 'smashing_flautist_access', true ) ); ?>" size="30" />
</p>
<?php }
With Justin’s code, modified for this project, we should have a custom meta box that looks like this:

A basic meta box positioned below the post editing box.
Adding Ease to the Selection
This box can be used as is, and the author would simply input the members who they want to allow to view a post. This would work well if each author had very few usernames to remember; but if the author has long list of usernames to choose from, then a list of members would have to be displayed, and there would have to be a system that allows the authors to choose members from the list. Add the following code to the area just below the original box, just after the closing paragraph tag, to display a list of users with their names, along with radio buttons to grant one of the users access to the current post.
<table class="smashing-flautist-access">
<tr align="left">
<th>Username</th>
<th> </th>
<th>Visiblity</th>
<th> </th>
<th>Name</th>
</tr>
<?php
global $post;
$users = get_users('role=subscriber');
foreach ($users as $user) {
$user_info = get_userdata( $user->ID );
if(get_post_meta( $object->ID, 'smashing_flautist_access', true ) == $user->user_login) $ifchecked = 'checked="checked" ';
echo "<tr>";
echo "<td>$user->user_login</td><td> </td>";
echo "<td align=\"center\"><input type=\"radio\" name=\"smashing-flautist-access\" id=\"smashing-flautist-access\" value=\"$user->user_login\" " . $ifchecked ."/></td><td> </td>";
echo "<td>$user_info->last_name, $user_info->first_name</td><td> </td>";
echo "</tr>";
unset($ifchecked);
} ?></table>
If everything goes well, you should end up with a box underneath the post editor that looks similar to the image below. The form containing the radio buttons gets a list of users that are listed as subscribers and makes the selection of the student with viewing permissions easy, all without the post’s author having to remember any usernames.

A meta box that contains a method to select the particular name and information of each user.
Saving the List
Now that we have generated a list that makes it easy for the authors to pick which members they want to be able to view particular posts, we have to create a system to add the list to WordPress’ MySQL database so that we can retrieve it later. We also need a way to tell WordPress to update this list of usernames in case the author decides later to add or remove someone from a particular post’s list of authorized viewers. The code provided by Justin does excellent work; place his code below in your theme’s functions.php, just after the function that sets up the custom meta box.
/* Save post meta on the 'save_post' hook. */
add_action( 'save_post', 'smashing_flautist_access_save_meta', 10, 2 );
/* Save the meta box's post metadata. */
function smashing_flautist_access_save_meta( $post_id, $post ) {
/* Make all $wpdb references within this function refer to this variable */
global $wpdb;
/* Verify the nonce before proceeding. */
if ( !isset( $_POST['smashing_flautist_access_nonce'] ) || !wp_verify_nonce( $_POST['smashing_flautist_access_nonce'], basename( __FILE__ ) ) )
return $post_id;
/* Get the post type object. */
$post_type = get_post_type_object( $post->post_type );
/* Check if the current user has permission to edit the post. */
if ( !current_user_can( $post_type->cap->edit_post, $post_id ) )
return $post_id;
/* Get the posted data and sanitize it for use as an HTML class. */
$new_meta_value = ( isset( $_POST['smashing-flautist-access'] ) ? sanitize_html_class( $_POST['smashing-flautist-access'] ) : '' );
/* Get the meta key. */
$meta_key = 'smashing_flautist_access';
/* Get the meta value of the custom field key. */
$meta_value = get_post_meta( $post_id, $meta_key, true );
/* If a new meta value was added and there was no previous value, add it. */
if ( $new_meta_value && '' == $meta_value )
{
add_post_meta( $post_id, $meta_key, $new_meta_value, true );
$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_status = 'private' WHERE ID = ".$post_id." AND post_type ='post'"));
}
/* If the new meta value does not match the old value, update it. */
elseif ( $new_meta_value && $new_meta_value != $meta_value )
{
update_post_meta( $post_id, $meta_key, $new_meta_value );
$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_status = 'private' WHERE ID = ".$post_id." AND post_type ='post'"));
}
/* If there is no new meta value but an old value exists, delete it. */
elseif ( '' == $new_meta_value && $meta_value )
{
delete_post_meta( $post_id, $meta_key, $meta_value );
$wpdb->query($wpdb->prepare("UPDATE $wpdb->posts SET post_status = 'public' WHERE ID = ".$post_id." AND post_type ='post'"));
}
}
The three MySQL queries are in place to prevent unauthorized users from viewing protected posts and to hide the posts from the RSS feeds. The first query runs only when new data populates the previously empty custom field, while the second query runs only when the data in the custom field has changed. The third query runs only if the custom field is emptied, and it sets the post’s visibility back to “Public.” All three are protected from SQL injection attacks by using $wpdb->prepare() to validate the data entered into the username form field.
If you don’t like that WordPress precedes the post’s title with the word “Private,” then add the following code to your theme’s functions.php file. This custom function is called when your theme would display a post’s title; it finds any instance of the words “Protected” or “Private” at the beginning of the title and removes them. In the core of WordPress’ programming, the function get_the_title() adds those words if a post’s visibility is restricted and the person viewing is not an administrator. What the following code does is send a message to the action that get_the_title() hooks into, telling it to remove the terms “Protected: ” and “Private: ” from the title. So, you can set a post’s title to begin with either term, and the title will not be altered; this code only affects WordPress’ ability to add to your title.
function smashing_title_trim($title) {
$title = attribute_escape($title);
$needles = array(__('Protected: '),__('Private: '));
$title = str_replace($needles,'',$title);
return $title;
}
add_filter('protected_title_format','smashing_title_trim');
add_filter('private_title_format','smashing_title_trim');
To allow users at the subscriber level to see private posts, you have to give them that capability. As it happens, some of the code we’ll be using later frees us from having to worry about users at the subscriber level seeing the posts of others.
$subRole = get_role( 'subscriber' ); $subRole->add_cap( 'read_private_posts' );
You can also grant users at the subscriber level permission to view private pages, in case you want a dedicated page of information that subscribers should know.
$subRole->add_cap( 'read_private_pages' );
Setting Up The Front End
Now that we have a way to add members to the list of people who can view a particular post, we have to modify our theme to use this data, and to actually control the visibility of each post based on this list. First, we need a way to get the username of the person who can view a post. Secondly, we would compare the username of the member with viewing permissions to the user who is currently logged in. Finally, we would make the theme display either the post in the loop or an error message (or perhaps nothing at all).
Place this code just after The Loop starts. It goes in single.php, category.php and index.php if you will be displaying posts on the home page.
<?php
/* Get the post's acceptable viewer. */
$flautist_access = get_post_meta($post->ID, 'smashing_flautist_access', true );
/* Get the post's current viewer, if he or she is logged in. */
if(is_user_logged_in()) {$current_flautist = $current_user->user_login;}
/* See if the acceptable viewer and the current viewer are the same */
if($flautist_access == $current_flautist || current_user_can('author') || current_user_can('editor') || current_user_can('administrator'))
{echo ''; ?>
Place this code just before the loop ends. Here is where you can show an error message telling the user that they may not view this post. Or you could leave this code as is to make it appear as though the current visitor is not missing anything.
<?php } else { echo ''; } ?>
This is what a hidden post looks like to the public or to a user who is not logged in. They would see what appears to be an error message and are redirected away from the post.

If a person is not logged in and tries to view a restricted post, they would get an error message.

If a user is logged in but not allowed to view a restricted post, they would see either nothing or an error message specific to members.

If a member is logged in and authorized to view a protected post, then they would see the post itself.
Conclusion
Being able to control who can view individual posts is a useful feature with a wide variety of applications. Third-party software can natively do this, but WordPress is widely supported and documented, which means that any security holes that might allow unauthorized users to view restricted posts would be shut in a future update. Plus, it allows you to run an actual blog next to posts with limited visibility. This system could be used by administrators to distribute personalized content, by professionals to send files to clients, or by bloggers to restrict the visibility of certain posts to certain members.
Enabling an author to control who can view their posts can help them tailor the blog’s content to the needs or tastes of certain users. Ultimately, you will have to factor in the purpose and content of your website when deciding whether to use this method. It’s not for everyone, but it suit the needs of owners of small websites who want to deliver certain content to certain people.
Resources
- “Function Reference/add meta box,” WordPress Codex
- “Function Reference/get users,” WordPress Codex
- “Roles and Capabilities,” WordPress Codex
- “Class Reference/wpdb,” WordPress Codex
- “How To Create Custom Post Meta Boxes In WordPress,” Justin Tadlock
(al)
© Chris Ellison for Smashing Magazine, 2012.






