Private pdf files

Your approach does not provide security. I could hand-craft a cookie named “wordpress_logged_in” (containing any arbitrary value) and have access to your PDF files. You may want to rethink your solution to put a PHP script in between the files and the users. e.g. User Clicks download button PHP Script handles fetching document If authenticated … Read more

Accessing private posts through REST API, same code that works in remote doesn’t in local

The problem was that I didn’t completely clone the wp site, and I forgot to install the plugin that I used to manage user roles The plugin is Members (“User Role Editor by Members – Best User, Role and Capability Management Plugin for WordPress”) by MemberPress, and there I can allow the roles that I … Read more

How to make comments private for commentor and post author

You can use the pre_get_comments filter to modify the parameters of the comment query before it fetches the comments. Specifically the author_in parameter. I tried to write an example, though I haven’t tested it, but it would be similar to this: add_action( ‘pre_get_comments’, ‘author_and_self_comment_filter’ ); function author_and_self_filter( \WP_Comment_Query $query ) : void { // We … Read more

Manage Private Posts

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 … Read more

How to properly print a 404 error without redirecton? (i.e. keeping the current URL)

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’ ); endif; return $template; } Your code is executed before the template is loaded, so it becomes … Read more

How to control who can view certain pages in BuddyPress? [closed]

I am new to BuddyPress so I don’t know which functions and variables to use here. Read the codex – for example: http://codex.buddypress.org/developer-docs/the-bp-global/ You could create a function in your theme- functions.php or in bp-custom.php and call it from template files and pass it parameters like allowed_users, etc. Or you code hard-code something like this … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)