Restrict post to user_id

I am not expert on users, simplest way as for me would be to store ID (or IDs) of user in custom field and check for it if user is not admin. Some example code (not tested): if(current_user_can(‘administrator’) || in_array(get_current_user_id(), get_post_meta(get_the_id(), ‘allowed_users’, true))) { the_content(); } else { echo ‘Post restricted’; }

front end editing using iFrames, best approach?

Using a custom template and wp_update_post you should be able to build your own edit/add post pages in your sites frontend. There are also various plugins available that attempt to do similar things. iFrames can be done, but it will need some checks in functions.php to check for a get variable and add conditional stylesheets … Read more

How to redirect specific post type with user role

add_action(‘load-index.php’, ‘redirect_dashboard’); function redirect_dashboard() { if ( ! is_admin() || current_user_can(‘activate_plugins’) ) return; $screen = get_current_screen(); if ( is_object($screen) && $screen->base == ‘dashboard’ ) { $url = admin_url(‘edit.php’); wp_safe_redirect( add_query_arg( array(‘post_type’ => ‘product’), $url) ); die(); } }

show text If special user is logged

I am not sure exactly what you are asking for, but, if you want to target a specific user ID, just do something like: // set special user id $special_user_id = 5; $current_user_id = get_current_user_id(); if ( $special_user_id == $current_user_id ){ echo ‘special user is online’; } You get the idea.

Redirect non-admin users away from wp-admin/index.php (main dashboard page) to wp-admin/profile.php

The easiest solution is to hook in load-index.php and redirect non-admin users to their profile. Effectively blocking access to that page. I’m going to wrap the permission check up in a function for this example (we’ll use it more than once). function _wpse206466_can_view() { // or any other admin level capability return current_user_can(‘manage_options’); } add_action(‘load-index.php’, … Read more

Plugin to restrict access to pages in wp-admin

if( is_admin() ) { add_filter( ‘init’, ‘custom_restrict_pages_from_admin’ ); } function custom_restrict_pages_from_admin() { global $pagenow; $arr = array( ‘update-core.php’, ‘edit.php’ ); if( custom_check_user_roles() && in_array( $pagenow , $arr ) ) { //echo some custom messages or call the functions } else { echo ‘This page has restricted access to specific roles’; wp_die(); } } function custom_check_user_roles() … Read more

How can we Restrict to access a certain wordpress page to all ip address except some which we allow

Haven’t specifically done this yet but something similar In the theme page/post template files you can get post id of current post/page by doing $currentID = get_the_ID(); Then redirect all traffic not from the specified IPs $ipArr = array(‘xx.xxx.xxx.xxx’, ‘xx.xxx.xxx.xxx’); if (!in_array(@$_SERVER[‘REMOTE_ADDR’], $ipArr)) { header(“Location: http://example.com/myhomepage”); die(); }

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