Add number of members to “Right Now” dashboard widget

So here is the small snippet to show total number of users and all roles with user count. This code should go in the themes functions.php file. The code uses count_user function to fetch the array and show it up on Right Now dashboard screen. function wpse_60487_custom_right_now() { $users = count_users(); echo ‘<table><tbody>’; echo ‘<tr><td … Read more

Execute PHP function inside the admin area

Hook into the admin_init action… add_action(‘admin_init’, ‘fetch_all_companies’); function fetch_all_companies() { //do something here… } note: What file are you running your fetch_all_companies() function from and where is it located (the path to the file)? Its likely the WordPress environment is not loaded on the destination file which is why your function appears to be undefined.

Adding link to dashboard sidebar, nested under custom post type

This should do it. function register_additional_page(){ add_submenu_page(‘edit.php?post_type=tree’, ‘Bulk Process’, ‘Bulk Process’, ‘activate_plugins’, ‘tree_bulk_process’, ‘render_bulk_tree_process’); } add_action(‘admin_menu’, ‘register_additional_page’); And the function that renders the page. function render_voucher_list_page(){ ?> <h2>Hello World</h2> <?php } Change post_type=tree to your Custom Post Type, Bulk Process to the menu title, activate_plugins to your desired user capability, tree_bulk_process to your page ‘slug’ … Read more

Adding a single text input field to a custom Dashboard widget

You need a set of functions to : process datas sanitize options allow datas to be updated output the form I like to proceed this way. I set also a function to grab datas so I can call them the simpliest way : add_action(‘wp_dashboard_setup’, ‘wpse_106458_add_widget’); function wpse_106458_add_widget() { $title = my_function_get_options(); $title = $title[‘title’]; wp_add_dashboard_widget(‘widget_id’, … Read more

WordPress Dashboard – Restricting Access

The content of the dashboard, however, will not be the same according to the role of the user. Contributor won’t see much of the menu, for example. A subscriber can only manage its own profile. Try to set up different users with different roles to see how the WP Admin is displayed for those users. … Read more

Modifying Dashboard edit.php

You could edit the columns for your CPT like so: function edit_cpt_columns($columns){ $columns = array( ‘cb’ => ‘<input type=”checkbox” />’, ‘title’ => __(‘Post’) ); return $columns; } add_filter(‘manage_edit-CPT_columns’, ‘edit_cpt_columns’); function manage_cpt_columns( $column, $post_id ) { global $post; switch( $column ) { case ‘title’ : $link = get_permalink($post->ID); echo ‘<a href=”‘.$link'”>’.$post->post_excerpt.'</a>’; break; default : break; } … Read more

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