Restrict access to post if it is currently being edited

The warning notice gets dispatched by the function wp_check_post_lock. The following redirects the user back to the post listing screen if someone else is editing it. add_action( ‘load-post.php’, ‘redirect_locked_post_wpse_95718’ ); function redirect_locked_post_wpse_95718() { if( isset($_GET[‘post’] ) && wp_check_post_lock( $_GET[‘post’] ) ) { global $typenow; $goto = ( ‘post’ == $typenow ) ? ” : “?post_type=$typenow”; … Read more

Hiding posts from non logged in users

Fiddling with user roles would probably be the most robust solution, however a quick and dirty approach would be to set post meta-data to mark posts that should be hidden, then add a meta-query to post queries by using a pre_get_posts hook in order to restrict results to non-hidden posts for non-logged-in users. The following … 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

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