Tag Info

Hot answers tagged

5

When a POST is set to private, non-logged in users will receive a 404 message. If you dump the global variable $wp_query, var_dump($wp_query); ..you will notice that no post_status is present in the parameters returned therefore using the slug (or name parameter of query_vars array for example) we can get the post status of the POST that is trying to be ...


5

Transients are persistent storage mechanism. That means that by saving transient with certain key you will be able able to retrieve same transient with that same key (if it had not expired and cache have not been flushed since). "Public" does not really apply to them, since they are internal code concept and only thing that accesses them is your code, not ...


5

Transients are just database keys that expire. It's like telling WordPress you want it to remember a certain piece of information, but for a limited time. In general, transients are accessible to PHP through any request. But since they're server-side, transients are only exposed to front-end users if you as the developer expose them. A Solution Given ...


4

The problem with the code in your question is it always intercepts. You completely lose the ability to not publish, no drafts possible. Why this leads to untrashable post is something I didn't inspect further. Anyway this isn't what one wants. I'm glad the javascript solution is working for you, but personally I have two problems with it, first, you can ...


4

Yes, you can set up a separate, private blog that requires members to log in. You can do this with a plug-in called Members Only - it's freely available from the WordPress plug-in repository. Anyone who visits the site who's not logged in will be directed automatically to the login screen. After users log in, they can browse the site normally. Edit ...


3

There is a plugin for that: Automatic Updates For Private And Commercial Plugins. To prevent upgrade checks against the WordPress.org data base in your plugin use the function Mark Jaquith has written.


3

You could redirect anything that's not a page or admin to home via the parse_query action: function wpa_parse_query( $query ){ if( !is_admin() && !$query->is_page ) wp_redirect( home_url() ); } add_action( 'parse_query', 'wpa_parse_query' ); If it's not an admin screen or a query for a page, it'll redirect. You can see all of the types of ...


3

Authenticator, a plugin on github https://github.com/bueltge/Authenticator uses HTTP Auth by default to get the functionality equivalent to Members Only. It also has the ability to create a token to work the same way Feed Keys work.


3

You should be using a filter outside of your template for this: add_filter( 'template_include', 'wpa62226_template_include', 1, 1 ); function wpa62226_template_include( $template ){ if( is_page( 'some-page' ) ) : global $wp_query; $wp_query->set_404(); status_header( 404 ); $template = locate_template( '404.php' ); ...


3

The problem is that changing the post visibility to private invokes a status change, in a way private is not only a visibility but also a publishing status. Or to quote the Wordpress Codex, section »Content Visibility - Private Content«. Once you change the visibility to private, the post or page status changes to "Privately Published" as shown. ...


3

I'm hereby answering my own question, because i found a solution, but I'm really interested in your opinions towards it. Or maybe you have a much better solution, if so, I really would like to here about it. Research result My research results were: 1. get the files outside of the document root, www folder; 2. disallow any direct access to the ...


3

This is challenging, because showing something would require page not to be private. It is more common to leave page public, but make it produce conditional output depending on if user is logged (is_user_logged_in()) in or other criteria.


2

You would be better suited by allowing members to sign up on your site, then giving each uses level permissions to read different posts. A plugin like Members might work for this. But, if you really want to do what you asked, you're going to have to do some javascript hacking or completely remove the publish meta box and roll your own. There's not a ton ...


2

Use this : http://wordpress.org/extend/plugins/password-protected/ A very simple way to quickly password protect your WordPress site with a single password. Integrates seamlessly into your WordPress privacy settings. How can I change the WordPress logo to a different image? Install and configure the Login Logo plugin by Mark Jaquith. This ...


2

I've been working on this a little bit, and this solution adds a new set of options to the "Privacy" settings page. function oxide_setup_options() { register_setting('oxide-privacy', 'blog_open'); $blog_open = get_option('blog_open'); if ( empty( $blog_open ) ) { add_option('blog_open', '0'); } } add_action('admin_init', ...


2

The easiest solution is to add a specific class to the menu items that you want to hide. And then hide them through CSS. ^ click to enlarge ^ The CSS classes are not visible by default, you have to enable it in the Screen Options upper tab. If your theme does not print the relevant classes in the <body> tag, this will do: add_filter( ...


2

I used this as a solution for hiding draft pages. You can hide the (draft page) menu items with the li.draft class. add_filter('nav_menu_css_class' , 'nav_menu_add_post_status_class' , 10 , 2); function nav_menu_add_post_status_class($classes, $item){ $post_status = get_post_status($item->object_id); $classes[] = $post_status; return ...


2

The easiest php solution would be to make a download script. It checks if the user has the right permissions and serves the file to the webclient. Or my preference setup a folder outside your web root and put the files there. Set the file permissions with no anonymous access and let the webserver read them and output them in a php file like this. The below ...


2

from the plugin; uses action 'post_submitbox_misc_actions' and some query to catch the user Publish form: http://wordpress.org/extend/plugins/private-post-by-default/ function default_post_visibility(){ global $post; if ( 'publish' == $post->post_status ) { $visibility = 'public'; $visibility_trans = __('Public'); } elseif ( !empty( ...


1

Sound like a nice idea, but when i need a per user customized private section i usually code it based on page template files and create a few pages with these template files fo example, say i have a download page which will show each user the files he can download so my page template would first check if the user is logged in (if not Unauthorized redirect) ...


1

If your on a company intranet it might be easier/more secure to just whitelist a few IP's and deny access to everything else, you can do that with apache config or .htaccess. Otherwise you will have to get people to login and then you can use a plugin like "Members Only", there are several of these for private blogs.


1

if you are worried about spams you should use a anti-spam plugin (Akismet comes by default you should configure it). For the session enabling and usage you wordpress session enabler (but i highly dough that it would be of much help). You can also use Registered Users Only, Members Only or registered users only 2 to force your users to login before the can ...


1

Without a plugin something like this should work //functions.php function get_user_role() { global $current_user; $user_roles = $current_user->roles; $user_role = array_shift($user_roles); return $user_role; } //page template $role = get_user_role(); if($role == "subscriber"){ //cool you can see this ...


1

I found the simplest way - just use Simply Exclude Wordpress plugin. It has the option to exclude each post (or tag, for that matter) from front page, archive, search or feed. It works flawlessly. You can still view the posts by using direct links.


1

The first thing you need to do is disable direct access to the directories the files are stored in by uploading blank index.html files to wp-content/uploads/ and all of its subdirectories. That way no one can go browsing around your upload directories finding that media manually. In order to keep search engines from crawling your protected pages and users ...


1

Search engines SHOULD respect the industry standard robots.txt file which you could use to block access to a post type. Such as blocking access to anything under example.com/deals. You could also go above and beyond and check the $_SERVER['HTTP_USER_AGENT'] for bots. Something like: $bot_list = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi", ...


1

Are you doing this inside The Loop? I'd try something like this myself: if ($post->post_status == "private" && !is_user_logged_in()) { echo "You must be logged in to view this page."; } else if( $post->post_status == "private" && is_user_logged_in() ) { // Page code goes here }


1

List Category Posts plugin uses get_posts to actually get the posts and its default post_status is publish and that is way you won't get any private posts. To "Fix" it you can edit the file named include/CatList.php of the plugin and add $lcp_query .= '&post_status=private'; before line 51 before $this->lcp_categories_posts = ...


1

You could perhaps: 1) Create the category for your Private posts, e.g. "Private" 2) Exclude the "Private" category from your main Loop 3) Output the "Private" category using a custom template file, e.g. category-private.php 4) Wrap the Loop in category-private.php in an if ( is_user_logged_in() ) conditional (This assumes, of course, that you are the ...


1

Solution pulled out of the comments: This bug has already been in the Trac for a long time, but isn't fixed! There is a workaround though. Use the Plugin PressPermit or hack the core as explained here: https://core.trac.wordpress.org/attachment/ticket/20114/20114.diff



Only top voted, non community-wiki answers of a minimum length are eligible