I have 4 roles users: admin - editor - author - contributor

  • admin can see all last edited pages
  • Editor can see all last edited pages too
  • author can see only his last edited page
  • Contributor can't see edited page (can't publish page)

I want to create metabox on the dashboard with 10 last edited pages but the metabox will be different for somes role users.

for administrator and editor it will be the seem. For author i need a specific metabox (showing only the edited page of the user) and for the contributor no metabox cause it can publish pages.

My code right now :

add_action( 'wp_dashboard_setup', 'admin_dashboard_last_edits_register' );

function admin_dashboard_last_edits_register() {
  __FUNCTION__, __( 'Last published pages ', 'admin-dashboard-last-edits' ), 'admin_dashboard_last_edits_dashboard_widget');

function admin_dashboard_last_edits_dashboard_widget() { 
  $posts = get_posts(
  array (
    'numberposts' => 10, 
    'post_type' => array ( 'page' ), 
    'orderby' => 'modified')

  if ( $posts ) {
    $date_format = get_option( 'date_format' );
    echo '<ul>';
    foreach ( $posts as $post ) {
      printf( __( '<li><a href="%1$s" title="Edit %3$s"><span class="dashicons dashicons-edit"></span></a> <a href="%2$s" title="View %3$s on Front-End">%3$s</a> <small>%4$s</small>', 'admin-dashboard-last-edits' ), esc_html( get_edit_post_link( $post->ID ) ), esc_html( get_permalink( $post->ID ) ), esc_html( $post->post_title ), esc_html( get_post_modified_time( $date_format, false, $post->ID, true )) ); 
    echo '</ul>';

  else {
    printf( __( 'No published page found.', 'admin-dashboard-last-edits') );


It work fine for administrator and editor and contributor. I have an issue with the author role cause the code can't generate metabox for this user role

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.