Admin: Custom Query Returning Permissions Error

I think the problem is that by just appending ?deleteUser=XX you get an ‘illegal’ url, for example: http://localhost/wordpress/wp-admin/edit.php?post_type=type&page=mypage?deleteUser=xxx Instead, use WordPress’ add_query_arg: $url = $_SERVER[‘REQUEST_URI’]; $url = add_query_arg(‘test’,’val’,$url); which gives: http://localhost/wordpress/wp-admin/edit.php?post_type=type&page=mypage&deleteUser=xxx Personally, I wouldn’t use $_SERVER[‘REQUEST_URI’]; and instead hard-code the url of the page using admin_url. Also, see @Joshua comments on using the WordPress in-built … Read more

How to hide plugin options for editors via functions.php

This should be easiest way, just add the line to wp-config.php, this will disable plugin and theme editor, both. define(‘DISALLOW_FILE_EDIT’,true); If you want to add codes into theme’s function, the code should work for you. function ra_block_tp_edit( $caps, $cap ) { if($cap == ‘edit_plugins’ ) $caps[] = ‘do_not_allow’; return $caps; } add_filter( ‘map_meta_cap’, ‘ra_block_tp_edit’, 10, … Read more

Control Users listed in Users List on dashboard

WordPress doesn’t know which user created which, so first you need to store the creator’s data in the newly created user meta so you can so something like this: add_action( ‘user_register’, ‘Store_creator’ ); function Store_creator($user_id){ $creator = wp_get_current_user(); //only do this when none admin creates the user if ( $creator->roles[0] == ‘administrator’ ) return; update_user_meta($user_id,’_creator’,$creator->ID); … Read more

Parsing post->ID in included plugin file

First issue- you can’t access any data because your AJAX request is an entirely separate request from the one that loaded the page you’re making the request from. This is not unique to WordPress. You have to pass the data you want to operate on along with your AJAX request. Second issue- calling your plugin … Read more

Prevent users in the backend from seeing WP/Plugin notifications and update annoucements?

Add this to your functions.php. if ( !current_user_can( ‘edit_users’ ) ) { //Change the edit_user” to whatever capability you need to retain the notifications add_action( ‘init’, create_function( ‘$a’, “remove_action( ‘init’, ‘wp_version_check’ );” ), 2 ); add_filter( ‘pre_option_update_core’, create_function( ‘$a’, “return null;” ) ); } Or if you want to show the notification to a specific … Read more

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