Remove admin AND editor from the “change role to” menu in user listing

Try using below code to remove administrator and editor option from drop down. Use editable_roles filter function wdm_user_role_dropdown($all_roles) { global $pagenow; if( current_user_can(‘editor’) && $pagenow == ‘user-edit.php’ ) { // if current user is editor AND current page is edit user page unset($all_roles[‘administrator’]); unset($all_roles[‘editor’]); } return $all_roles; } add_filter(‘editable_roles’,’wdm_user_role_dropdown’);

How to listen to color changes on the color picker?

I hate answering my own question, but hopefully this can help someone else with similar issues: WordPress uses Iris color picker. http://automattic.github.io/Iris/# WordPress also creates a jquery widget with default settings for Iris. The file can be found under wp-admin/js/color-picker.js At first I was trying to pass values directly to iris(), which works, but that … Read more

How can I send data to admin-ajax via JS Fetch?

Is it proper way to pass the data in the form like I did? If you mean the body part (of your fetch() call), then yes, it is okay. However, You must send a query named action as part of the request (e.g. via the URL like example.com/wp-admin/admin-ajax.php?action=test), so that WordPress knows what AJAX action … Read more

Remove ability to access certain admin menus

I figured it out in the end and this is the code I used: function restrict_menus() { $author = wp_get_current_user(); if( isset( $author->roles[0] ) ) { $current_role = $author->roles[0]; } else { $current_role=”no_role”; } if( ‘contributor’ == $current_role ) { $screen = get_current_screen(); $base = $screen->id; if( ‘edit-post’ == $base || ‘upload’ == $base || … Read more

jQuery UI in Admin (Best Practice?)

WP 3.1 will come with jQuery UI 1.8 so the easiest solution would be to wait. Also, it sounds like you’re outputting the script tag directly. You should try deregistering the bundled jQuery UI version and replacing it with your own. This is done using wp_deregister_script() and wp_enqueue_script().

Permalinks Question: Adding a prefix ONLY in front of the posts

1) Add this rewrite at the end of you function.php function add_rewrite_rules( $wp_rewrite ) { $new_rules = array( ‘YOUR_PREFIX/(.+?)/?$’ => ‘index.php?post_type=post&name=”. $wp_rewrite->preg_index(1), ); $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } add_action(“generate_rewrite_rules’, ‘add_rewrite_rules’); function change_blog_links($post_link, $id=0){ $post = get_post($id); if( is_object($post) && $post->post_type == ‘post’){ return home_url(‘/YOUR_PREFIX/’. $post->post_name.”https://wordpress.stackexchange.com/”); } return $post_link; } add_filter(‘post_link’, ‘change_blog_links’, 1, 3); 2) … Read more

Filter by custom Field for Custom post type Admin Listing

I had to modify max answer to get the filter working. Renaming the select to issue_restrict_articles stopped it incorrectly filtering & kept the filter controls on the screen. posts_where filter and a SQL query to actually filter. function restrict_articles_by_issue() { global $wpdb; $issues = $wpdb->get_col(” SELECT DISTINCT meta_value FROM “. $wpdb->postmeta .” WHERE meta_key = … Read more

Turn off admin emails for new user registrations

Function wp_new_user_notification is pluggable. It means that you can override it by declaring your version of this function in your plugin/theme. So, if you wish to disable all notifications completely, do it like this: if ( !function_exists( ‘wp_new_user_notification’ ) ) : function wp_new_user_notification( $user_id, $plaintext_pass=”” ) { return; } endif; However I wouldn’t recommend you … Read more