Skip to content

Instantly share code, notes, and snippets.

@Luciaisacomputer
Last active December 11, 2015 19:40
Show Gist options
  • Save Luciaisacomputer/5a77e5702df9ad81b65f to your computer and use it in GitHub Desktop.
Save Luciaisacomputer/5a77e5702df9ad81b65f to your computer and use it in GitHub Desktop.
<?php
//***MEGA REMOVAL OF BACKEND THINGS**********************************************
//There is apparently no easy way to remove the fields, so you have to
//unset some, filter others, and inline hide one or two
//sorry in advance for this mess of spaghetti code
//********************************************************************************
//Remove Admin Color Scheme Options from WordPress dashboard
remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
if ( ! function_exists( 'cor_remove_personal_options' ) ) {
/**
* Removes the leftover 'Visual Editor', 'Keyboard Shortcuts' and 'Toolbar' options.
*/
function cor_remove_personal_options( $subject ) {
$subject = preg_replace( '#<h3>Personal Options</h3>.+?/table>#s', '', $subject, 1 );
return $subject;
}
function cor_profile_subject_start() {
ob_start( 'cor_remove_personal_options' );
}
function cor_profile_subject_end() {
ob_end_flush();
}
}
add_action( 'admin_head-user-edit.php', 'cor_profile_subject_start' );
add_action( 'admin_footer-user-edit.php', 'cor_profile_subject_end' );
// Remove Default Bio Field From User Profile Pages
function remove_plain_bio($buffer) {
$titles = array('#<h3>About Yourself</h3>#','#<h3>About the user</h3>#');
$buffer=preg_replace($titles,'<h3>Password</h3>',$buffer,1);
$biotable='#<h3>Password</h3>.+?<table.+?/tr>#s';
$buffer=preg_replace($biotable,'<h3>Password</h3> <table class="form-table">',$buffer,1);
return $buffer;
}
function profile_admin_buffer_start() { ob_start("remove_plain_bio"); }
function profile_admin_buffer_end() { ob_end_flush(); }
add_action('admin_head', 'profile_admin_buffer_start');
add_action('admin_footer', 'profile_admin_buffer_end');
//Remove the Your Profile Field Settings
function remove_website_row_wpse_94963_css()
{
echo '<style>tr.user-url-wrap{ display: none; }</style>';
}
add_action( 'admin_head-user-edit.php', 'remove_website_row_wpse_94963_css' );
add_action( 'admin_head-profile.php', 'remove_website_row_wpse_94963_css' );
function hide_personal_options(){
echo "\n" . '<script type="text/javascript">jQuery(document).ready(function($) { $(\'form#your-profile > h3:first\').hide(); $(\'form#your-profile > table:first\').hide(); $(\'form#your-profile\').show(); });</script>' . "\n";
}
add_action('admin_head','hide_personal_options');
//Hide the Website Field
function mod_backend_new_user_fields() { ?>
<script type="text/javascript">
// Remove selected fields only
var hideFields = ["url" ];
jQuery.each( jQuery( "tr.form-field" ), function() {
var field = jQuery( this ).find( "input" ).attr( "id" );
if ( hideFields.indexOf( field ) != -1 ) {
jQuery( this ).remove();
}
});
</script>
<?php }
add_action( 'admin_footer-user-new.php', 'mod_backend_new_user_fields' );
//Hides the Unused Roles
add_action( 'editable_roles' , 'hide_unused_roles' );
function hide_unused_roles( $roles ){
unset( $roles['contributor'] );
unset( $roles['author'] );
unset( $roles['editor'] );
return $roles;
}
//**** END OF THE SPAGHETTI!!!!!!!!~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment