Display protected posts to logged in users
-
Hi, I have a website which uses some password protected posts. My visitors (mostly family and friends) are able to view the posts, by using this password, without requiring a userid.
I’m now migrating to user logins (through facebook connect plugin), and want to allow those logged in users to see the protected posts, without having to enter the password for this page. Googled for days, but could not find anything on this.
Already tested several things by modifying the protected-post-personalizer plugin (great plugin btw.), but unsuccesful.
For protected pages, I don’t seem to be able to get the real content of the post (as I can see it in the database with phpMyAdmin) using the $post_content variable.
Want to allow the display of the content for is_user_logged_in().
Anyone already looked at doing something similar, and can provde some tips? Is there another way to retrieve the content, rather than through $post_content?function show_content_for_passworded( $input ){ global $post; if ( empty($post->post_password) || is_user_logged_in() ) { // if there's no password or logged in user return $post_content; } else { if ( !isset($_COOKIE['wp-postpass_'.COOKIEHASH]) || $_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password ) { // and it doesn't match the cookie
Am I completely on the wrong track?
Thanks,
Arnaud
- The topic ‘Display protected posts to logged in users’ is closed to new replies.