Support

Account

Home Forums Add-ons Gallery Field How to set Gallery Field height? Reply To: How to set Gallery Field height?

  • Hi all.
    In your functions.php add the code below:

    
    // We hook the function to "show_user_profile" and "edit_user_profile"
    add_action( 'show_user_profile', 'extra_profile_fields', 10 );
    add_action( 'edit_user_profile', 'extra_profile_fields', 10 );
    // And we updating custom user meta fields
    add_action( 'personal_options_update', 'save_extra_profile_fields' );
    add_action( 'edit_user_profile_update', 'save_extra_profile_fields' );
    
    function extra_profile_fields( $user ) {
      $settings = get_user_meta( $user->ID, 'acf_user_settings', true );
    ?>
    
    <h3><?php _e('Extra User Details'); ?></h3>
    <table class="form-table">
      <tr>
        <th><label for="gallery_height">ACF gallery field height</label></th>
          <td>
    	<input type="text" name="acf_user_settings[gallery_height]" id="gallery_height" value="<?=esc_attr($settings['gallery_height']);?>" class="regular-text" /><br />
    	<span class="description">Number.</span>
          </td>
      </tr>
    </table>
    <?php
    }
    
    function save_extra_profile_fields( $user_id ) {
      if ( !current_user_can( 'edit_user', $user_id ) ){
        return false;
      }
    
      /* Edit the following lines according to your set fields */
      update_usermeta( $user_id, 'acf_user_settings', $_POST['acf_user_settings']);
    }
    // End