Allow access on a page to just only a specific member

The same concept as Dominic’s (no need of a members plugin) but expanded to use a Meta Box, visible only for Admins, with a dropdown list with all the users (with exceptions). Code borrowed and adapted from this answer. Put in functions.php: // List Users add_action( ‘admin_init’, ‘wpse_33725_users_meta_init’ ); // Save Meta Details add_action( ‘save_post’, … Read more

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

Removing WordPress Plugin Menu Item for a specific user

Here is the code you need: global $current_user; get_currentuserinfo(); if ( $current_user->user_login === ‘brian’ ) remove_action( ‘admin_menu’, ‘wpcf7_admin_menu’, 9 ); Or if you want to retain your own code, use this: function remove_menus() { global $menu; global $current_user; get_currentuserinfo(); if($current_user->user_login == ‘brian’) { $restricted = array(__(‘Media’), __(‘Links’), __(‘Pages’), __(‘Comments’), __(‘Appearance’), __(‘Plugins’), __(‘Users’), __(‘Tools’), __(‘Settings’), __(‘Contact’) … Read more

Restrict certain posts from being sent to the feed subscribers

Simple answer is yes you can. 🙂 First check out WordPress’s codex here on their RSS feeds. http://codex.wordpress.org/WordPress_Feeds Then what you can do is change the default head rss links that let browsers know that there is an RSS feed. In your theme find: <link rel=”alternate” type=”application/rss+xml” title=”RSS 2.0″ href=”https://wordpress.stackexchange.com/questions/70834/<?php bloginfo (“rss2_url’);?>” /> And replace … Read more

Restrict backend but allow to use post.php?action=delete&post=POSTID from front-end

This will allow you to access post.php and still restrict the back-end. You need have action, action name as delete, post key and value, and wpnonce kay and value. Otherwise, it will redirect you to homepage. function disable_wp_admin() { if ( ! is_admin() ) return; if ( current_user_can( ‘manage_options’ ) ) return; if (( current_user_can( … Read more

Restrict access to the Trash folder in Posts

With the filter we prevent the Trash link from being printed. And with the action, redirect back to the post listing page if the user tries to access the URL directly (/wp-admin/edit.php?post_status=trash&post_type=post). add_filter( ‘views_edit-post’, ‘wpse_74488_remove_trash_link’ ); add_action( ‘admin_head-edit.php’, ‘wpse_74488_block_trash_access’ ); function wpse_74488_remove_trash_link( $views ) { if( !current_user_can( ‘delete_plugins’ ) ) unset( $views[‘trash’] ); return $views; … Read more

Restrict the user access in multi site for non-assigned blogs

is_user_logged_in() is a pluggable function, which means you can override its functionality. That’s probably where I’d start. Something like this may do what you’re looking for. This is untested code and comes with no warranties of any kind. function is_user_logged_in() { $user = wp_get_current_user(); $current_blog_id = get_current_blog_id(); $allowed = false; $blogs_of_user = get_blogs_of_user( $user->ID ); … Read more

how to make author to write comment on only his own posts?

I have the same thing running on my website. Here is how I do do it… Only post author and commentor can view each others comments function restrict_comments( $comments , $post_id ){ global $post; $user = wp_get_current_user(); if($post->post_author == $user->ID){ return $comments; } foreach($comments as $comment){ if( $comment->user_id == $user->ID || $post->post_author == $comment->user_id ){ … Read more

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