I´m using a plugin called "private content login redirect". The plugin is actually only containing this piece of code: add_action('template_redirect', 'private_content_redirect_to_login', 9); function private_content_redirect_to_login() { global $wp_query,$wpdb; if (is_404()) { $private = $wpdb->get_row($wp_query->request); $location = wp_login_url($_SERVER["REQUEST_URI"]); if( 'private' == $private->post_status ) { wp_safe_redirect($location); exit; } } } What it does is this: When a non-logged in user is viewing a private page, it redirects them to the log-in page. After they log in, they are taken back to the private …
I've created a custom role via add_role, it's in my activation hook and is being removed on deactivation, thus I'm deactivating and reactivating my plugin to see the role permission changes. I can see that the changes are appearing (I've used the User Roles and Capabilities plugin to check) but I still can't view private page and posts when logged in. add_role( 'clerk', 'Clerk', [ 'read' => true, 'read_private_pages' => true, 'read_private_posts' => true ] ); I've even tried adding …
I am trying to make comments private. I mean comment must be visible for post author and comment author. I create custom comment section "better-comment.php". I have used pre_get_comments but I can not make work. Please help <?php // My custom comments output html function better_comments( $comment, $args, $depth ) { // Get correct tag used for the comments if ( 'div' === $args['style'] ) { $tag = 'div'; $add_below = 'comment'; } else { $tag = 'li'; $add_below = …
How can i create private category in Wordpress? What i mean? Authors can't see the category and can't add that category to their posts but admins and editors are can see that category and add the everyones posts. Such as: Editor's Picks category. How can we do that? Note: I want to do that without plugins.
I have a wordpress web site with only a private pages (can only be viewed by logged users) I use the below code in my theme functions.php to be redirected to login page each time a put the page URL on the browser. add_action( 'wp', 'redirect_private_page_to_login' ); function redirect_private_page_to_login(){ $queried_object = get_queried_object(); if ( isset( $queried_object->post_status ) && 'publish' === $queried_object->post_status && ! is_user_logged_in() ) { wp_safe_redirect( wp_login_url( get_permalink( $queried_object->ID ) ) ); exit; } } When i put my …
I'm trying to completely disable access to my parents page menu. For example, I have a menu made like this : parent page -> child page 1 -> child page 2 I made a real page for 'parent page' because my backend is better organized. But I don't want that my customers go to www.mysite/parent-page I tried to put that page in "private" but then on my breadcrumbs child page 1 I have : "home > parent page(private) > child …
I am trying to set a Post's default visibility to 'Private' when a user first creates the post. They should then have the ability to manually select 'published' from the sidebar dropdown once they are ready or the post has been reviewed. My goal is to ensure posts aren't accidentally published if the user isn't ready or forgot to select 'private'. I can't find any code that works for Gutenberg. Most I researched are outdated and for the classic editor. …
I am working on a wordpress site for a client who wants an internal 'intranet' for his employees. The basic needs are: Communicate things in-house House important company documents Provide quick access to resources to employees. This info is sensitive and for employees only. They would like each employee to have a user name / password and only be able to view information and documents once they are logged in. I saw these plugins, and a few like it, but …
I am trying to list all private pages that user has access to read. To explain in more details, below is the initial setup: Each user has a specific role created and assigned only ability to read private pages. Then these roles are selected for specific pages to limit access to that page. Example: "user 1" role name = "user_1_role", capabilities = "Read Private Pages" "user 2" role name = "user_2_role", capabilities = "Read Private Pages" "Page 1", visibility set …
Private posts are visible only to administrators and editors, but I have found that they are displayed publicly in RSS feeds. How can I remove them from there? I have this code but it doesn't work: function removeRssPrivatePost($content) { global $post; if ($post->post_status == 'private') { return; } return $content; } add_filter('the_excerpt_rss', 'removeRssPrivatePost'); add_filter('the_content_feed', 'removeRssPrivatePost');
I would like to give access some private pdf files to only logged in users. I have this in my htaccess: RewriteCond %{REQUEST_FILENAME} ^.*(pdf)$ RewriteCond %{HTTP_COOKIE} !^.*wordpress_logged_in.*$ [NC] RewriteRule . - [R=403,L] But I want to restrict access only documents .pdf with name starts with "private_". Example: private_document1.pdf and private_document2.pdf only have to be accessible by logged in users. Please, any ideas?
I have a class with some private & public functions. The thing is that I don't want some of the functions to be able to be called outsite of the class, so I want to make them private. But I need to hook them at particular hooks and the hooks cannot call them if they are private. Is there some workaround for that?
By default WordPress pushes out a whole array of pages I don’t want or need - archive, author, blog, monthly, recent posts, categories, comments, attachment, taxenomies, search, search results, and probably a few others I’ve missed. Most of the time I’m building regular broshure websites with no need for anything except a few fairly static pages. How do I get rid of all the other pages? Is there a plugin that will do this? Do I have to set up …
I would like to create a menu or menu item that can only be seen with a private link. So the menu would house various pages, but the content can only be seen with a link that is shared. I have searched the plugins and cannot find one to do this. Most plugins require user logins and it would be my preference not to have users if possible. Help is greatly appreciated!
I want private posts (for those not logged in) to use the single.php template just as public posts do, at the moment they get thrown over to the 404.php template. I've had a good look through the core files but I cannot find where the template change (note: this is not a redirect) happens. Can anyone help? Edit To explain why I want this, I want all visitors to see a preview of the content, but logged in "members" to …
Say I created a custom post type called 'Private Posts' ($post_type = itsme_private_posts) and want all posts under the custom post type to be set to 'Private' automatically when published i.e. by default. How do I do it? Based on @brasofilo's answer to a related question on StackOverflow, I tried this: add_filter( 'wp_insert_post_data', 'itsme_cpt_private', '99', 2 ); function itsme_cpt_private( $data , $postarr ) { if( $postarr['post_type'] == 'itsme_private_posts' ) { $data['post_status'] = 'private'; } return $data; } It doesn't work …
right now I have WP_Query stored for 24h (1day) with set_transient function. Everything works fine like it should. But if for example I change the post which is in the stored array to private or modify its meta_value, the post will still be seen on frontend. Any way to check if the post values have been modified? or I should use some other function for that? The code: if (false === ($loop = get_transient('randomizeProfiles'))) { $loop = new WP_Query(array( 'post_type' …
I registered a new custom post type and forced it to be private, but now I need to use three custom post type. I registered the second one, but I don't know hot to set the code to force the second one. Here is the code I used to force the first CPT ('my_post_type1') function force_type_private($post) { if ($post['post_type'] == 'my_post_type1') { $post['post_status'] = 'private'; } return $post; } add_filter('wp_insert_post_data', 'force_type_private'); How can I force the second ('my_post_type2')? Thank you …