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
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.