Skip to content

Instantly share code, notes, and snippets.

@glennansley
Created April 4, 2013 14:21
Show Gist options
  • Save glennansley/5310749 to your computer and use it in GitHub Desktop.
Save glennansley/5310749 to your computer and use it in GitHub Desktop.
Disable access to WordPress DB upgrade script unless user has permission to upgrade core. Place this at the bottom of wp-config.php
/** Restrict access to the DB upgrade script **/
if ( 'upgrade.php' == $pagenow ) {
if ( ! current_user_can( 'update_core' ) ) {
$url = is_user_logged_in() ? get_admin_url() : add_query_arg( array( 'redirect_to' => get_home_url() . '/wp-admin/upgrade.php' ), get_admin_url() );
wp_safe_redirect( $url );
die();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment