diff --git a/includes/forms/form-user.php b/includes/forms/form-user.php index 14531b58..28e7eda7 100644 --- a/includes/forms/form-user.php +++ b/includes/forms/form-user.php @@ -28,6 +28,7 @@ function __construct() { // enqueue add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) ); add_action( 'login_form_register', array( $this, 'login_form_register' ) ); + add_action( 'admin_head', array( $this, 'scf_user_form_layout_fix' ), 20 ); // render add_action( 'show_user_profile', array( $this, 'render_edit' ) ); @@ -64,6 +65,82 @@ function admin_enqueue_scripts() { // enqueue acf_enqueue_scripts(); } + /** + * Fix SCF field layout on user profile/edit screens. + * + * SCF fields on user screens render inside WordPress `table.form-table` rows, + * so we apply scoped CSS only on profile.php and user-edit.php screens. + * + * @see https://github.com/WordPress/secure-custom-fields/issues/349 + */ + function scf_user_form_layout_fix() + { + + // Only run in wp-admin, and only on profile/edit user screens. + if (!is_admin()) { + return; + } + + $screen = function_exists('get_current_screen') ? get_current_screen() : null; + if (!$screen || !in_array($screen->base, array('profile', 'user-edit'), true)) { + return; + } + + ?> + +