echo or print_r in an admin function

After the save_post hook is executed, the page is redirected, so you’re not able to see the print_r output. A simple method, if you can afford it, is to do a wp_die() just after the print_r or var_dump. Or you can check other debugging methods, like FirePHP.

Enqueue jQuery UI Tabs In Admin Area

I normally load it as a dependancy of my plugin’s js file like so: if ( is_admin() ) { //load my plugin’s js add_action(‘admin_print_scripts’, ‘my_plugin_load_js’ ); } function my_plugin_load_js() { $plugin_js = WP_PLUGIN_URL . “https://wordpress.stackexchange.com/” . plugin_basename( dirname(__FILE__) ) . ‘/my-plugin.js’; wp_enqueue_script(‘my-plugin-js’, $plugin_js, array(‘jquery-ui-tabs’), ‘1.0’); }

Add a custom column in users list page

One thing you should remember is that function, which will be hooked into manage_users_custom_column action must have 3 parameters, the first of which (i.e. $val) should be the returned value: // Add custom column using ‘manage_users_columns’ filter if(!function_exists(‘bm_utm_column’)){ function bm_utm_column($columns) { return array_merge( $columns, array(‘utm_source’ => __(‘UTM source’), ‘utm_medium’ => __(‘UTM medium’) ) ); } … Read more

wordpress upload http error?

Are you on shared hosting by any chance? Shared hosts tend to limit the max uploadable file size on their end and there is nothing you can add to your scripts to change that. If not, then I am mistaken and this is not the solution you are looking for. However, if you are on … Read more

WordPress Left Hand Side Admin Menu Always Collapsed

This will properly override the user settings to keep the menu collapsed for all users: /** * Reset user setting to always collapse the admin menu. * * @see set_user_setting() */ function wpdocs_always_collapse_menu() { if ( ‘f’ != get_user_setting( ‘mfold’ ) ) { set_user_setting( ‘mfold’, ‘f’ ); } } add_action( ‘admin_head’, ‘wpdocs_always_collapse_menu’ );

Replacing the List table of a Post Type

No, you cannot replace the list table. There is no filter, everything is hard-coded. But you can change the post type registration, set show_ui to FALSE to prevent the built-in page, and add a custom page for the post type listing to show the editable items. add_action( ‘wp_loaded’, function(){ register_post_type( ‘test’, array( ‘labels’ => array( … Read more

Hide Admin menus per role in WordPress

you can do this, it hides the menu (thats all , they can still go to the menu url if they know it), based on capability. You can easily change it to role or even username. I think user role is “user_role” and for username it is “user_login”. The example below uses “user_level” of 10 … Read more