【发布时间】:2015-12-08 20:14:51
【问题描述】:
在个人资料页面(用户可以编辑他的详细信息)有部分“个人选项”和“管理员配色方案”等。
我知道如何使用 CSS / jQuery 删除它。
如何使用钩子/过滤器/php 代码删除该部分?
谢谢。
【问题讨论】:
标签: php wordpress wordpress-hook
在个人资料页面(用户可以编辑他的详细信息)有部分“个人选项”和“管理员配色方案”等。
我知道如何使用 CSS / jQuery 删除它。
如何使用钩子/过滤器/php 代码删除该部分?
谢谢。
【问题讨论】:
标签: php wordpress wordpress-hook
这样就可以了:
// removes the `profile.php` admin color scheme options
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-profile.php', 'cor_profile_subject_start' );
add_action( 'admin_footer-profile.php', 'cor_profile_subject_end' );
在这里找到:
https://wordpress.stackexchange.com/questions/49643/remove-personal-options-section-from-profile
更新
这也是一个 JS(确切地说是 jQuery)hack...
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');
在这里找到:
https://premium.wpmudev.org/blog/how-to-simplify-wordpress-profiles-by-removing-personal-options/
【讨论】: