WordPress - 隐藏个人资料页面中的个人设置

时间:2015-12-08 20:14:51

标签: php wordpress wordpress-plugin wordpress-hook

在个人资料页面(用户可以编辑他的详细信息)中有部分"个人选项"使用"管理员配色方案"等

我知道如何使用CSS / jQuery删除它。

我怎么能用hook / filter / php代码删除那个部分?

感谢。

1 个答案:

答案 0 :(得分:2)

这样可以解决问题:

// 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/