Restrict access to specific users

This should do it. Place it in your theme’s functions.php or a plugin. function tst($a) { if (!current_user_can(‘edit_posts’)) { wp_die(‘You are not allowed to view this page’); } } add_filter(‘template_redirect’,’tst’); You can still get to the login page like normal by going to “/wp-login.php” or “/wp-admin”. Alternately, you could use wp_safe_redirect or wp_redirect instead of … Read more

How to restrict a page [without plugin]

You can do this pretty easily with a shortcode. Hook into init and add the shortcode in your hooked function. <?php add_action(‘init’, ‘wpse57819_add_shortcode’); /** * Adds the shortcode * * @uses add_shortcode * @return null */ function wpse57819_add_shortcode() { add_shortcode(‘restricted’, ‘wpse57819_shortcode_cb’); } Then in your callback function, you can check to see if the user … Read more