How do I find all admin users using phpmyadmin?

We can generate the SQL with: $query = new WP_User_Query( [ ‘role’ => ‘Administrator’, ‘count_total’ => false, ] ); echo $query->request; that outputs: SELECT wp_users.* FROM wp_users INNER JOIN wp_usermeta ON ( wp_users.ID = wp_usermeta.user_id ) WHERE 1=1 AND ( ( ( wp_usermeta.meta_key = ‘wp_capabilities’ AND wp_usermeta.meta_value LIKE ‘%\”Administrator\”%’ ) ) ) ORDER BY user_login … Read more

Pre-fill fields with content from outside when creating a new post

An empty post is created by get_default_post_to_edit(). This function reads the post_title, content and excerpt values in the $_REQUEST array, and also filters them through default_title, default_content and default_excerpt. By default this function only returns a “fake” $post object, but if the $create_in_db parameter is set to true, it is actually saved in the database … Read more

Disable wp-admin console for subscribers

You can remove the Read capability. That will prevent all access to wp-admin. function remove_read_wpse_93843(){ $role = get_role( ‘subscriber’ ); $role->remove_cap( ‘read’ ); } add_action( ‘admin_init’, ‘remove_read_wpse_93843’ ); See the note in the Codex about only needing to run this once. Then you need to hide the admin bar. function hide_admin_wpse_93843() { if (current_user_can(‘subscriber’)) { … Read more

How to change the wording in wp-admin back-end?

You can use the filter admin_post_thumbnail_html: function custom_admin_post_thumbnail_html( $content ) { return $content = str_replace( __( ‘Set featured image’ ), __( ‘Set featured image – 50 pixels by 50 pixels’ ), $content ); } add_filter( ‘admin_post_thumbnail_html’, ‘custom_admin_post_thumbnail_html’ );

Uploading Images in the Link Manager

Well, started as a curiosity, ended up doing a plugin… : After finishing, I went to look in WordPress repository and…yes, there’s already one that does it: Easy Blogroll Image : At least, I took a different approach and did something different. Featured Link Image – [edit: released in the WordPress repository, link updated]

How to Remove All Admin Bar Menu Items?

I’m solving this getting all nodes from the Admin Bar, iterating through them and removing all that doesn’t have a parent. An exception is made to the User Actions menu (“Howdy, user_name”), which needs an extra checking. add_action( ‘admin_bar_menu’, ‘wpse_76491_admin_bar_menu’, 200 ); function wpse_76491_admin_bar_menu() { global $wp_admin_bar; if ( !is_object( $wp_admin_bar ) ) return; // … Read more

Make fonts.com font work in TinyMCE (iframe referrer issue)

I ran into this issue with Typekit, here’s my solution: http://www.tomjn.com/150/typekit-wp-editor-styles/ add_filter(“mce_external_plugins”, “tomjn_mce_external_plugins”); function tomjn_mce_external_plugins($plugin_array){ $plugin_array[‘typekit’] = get_template_directory_uri().’/typekit.tinymce.js’; return $plugin_array; } and this js: (function() { tinymce.create(‘tinymce.plugins.typekit’, { init: function(ed, url) { ed.onPreInit.add(function(ed) { // Get the DOM document object for the IFRAME var doc = ed.getDoc(); // Create the script we will add to … Read more

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