Title: Set default on datepicker
Last modified: August 20, 2016

---

# Set default on datepicker

 *  Resolved [pfrey](https://wordpress.org/support/users/pattyfresonke/)
 * (@pattyfresonke)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/set-default-on-datepicker/)
 * How can I go about setting the current date in the datepicker? And can I remove
   the ‘day’ by simply removing it from the code?
 * [http://wordpress.org/extend/plugins/buddypress-xprofile-custom-fields-type/](http://wordpress.org/extend/plugins/buddypress-xprofile-custom-fields-type/)

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Plugin Author [donmik](https://wordpress.org/support/users/atallos/)
 * (@atallos)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/set-default-on-datepicker/#post-3638410)
 * It’s already set to current date or you are saying you want to put current date
   by default in field ? You cannot remove the day from a datepicker, it’s a html5
   field.
 *  Thread Starter [pfrey](https://wordpress.org/support/users/pattyfresonke/)
 * (@pattyfresonke)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/set-default-on-datepicker/#post-3638513)
 * I want to set the current date in the field, so the user doesn’t have to click
   anything for today’s date.
 *  Plugin Author [donmik](https://wordpress.org/support/users/atallos/)
 * (@atallos)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/set-default-on-datepicker/#post-3638523)
 * Replace the code below of bxcft_edit_render_new_xprofile_field function:
 *     ```
       elseif ( bp_get_the_profile_field_type() == 'datepicker' ) {
              ?>
               <div class="input-web">
                   <label class="label-form <?php if ( bp_get_the_profile_field_is_required() ) : ?>required<?php endif; ?>" for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) { echo __('*', 'bxcft'); } ?></label>
                   <input type="date" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true" required="required"<?php endif; ?> class="input" value="<?php bp_the_profile_field_edit_value() ?>" />
              </div>
              <?php
              }
       ```
   
 * By this code:
 *     ```
       elseif ( bp_get_the_profile_field_type() == 'datepicker' ) {
             if (bp_get_the_profile_field_edit_value() != '')
                 $value = bp_get_the_profile_field_edit_value();
             else
                 $value = 'put your default date here';
              ?>
               <div class="input-web">
                   <label class="label-form <?php if ( bp_get_the_profile_field_is_required() ) : ?>required<?php endif; ?>" for="<?php bp_the_profile_field_input_name() ?>"><?php bp_the_profile_field_name() ?> <?php if ( bp_get_the_profile_field_is_required() ) { echo __('*', 'bxcft'); } ?></label>
                   <input type="date" name="<?php bp_the_profile_field_input_name() ?>" id="<?php bp_the_profile_field_input_name() ?>" <?php if ( bp_get_the_profile_field_is_required() ) : ?>aria-required="true" required="required"<?php endif; ?> class="input" value="<?php echo $value; ?>" />
              </div>
              <?php
              }
       ```
   
 * Tell me if this works.
 *  Thread Starter [pfrey](https://wordpress.org/support/users/pattyfresonke/)
 * (@pattyfresonke)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/set-default-on-datepicker/#post-3638539)
 * Well, I wasn’t really sure what to put in _$value = ‘put your default date here’;_
   but I tried _date(“j F Y”)_ and that didn’t seem to do anything to the datepicker
 *  Plugin Author [donmik](https://wordpress.org/support/users/atallos/)
 * (@atallos)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/set-default-on-datepicker/#post-3638570)
 * You need to use this format:
 * `date('Y-m-d')`
 *  Thread Starter [pfrey](https://wordpress.org/support/users/pattyfresonke/)
 * (@pattyfresonke)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/set-default-on-datepicker/#post-3638592)
 * Still not seeing a value come into those dropdowns…
 *  Plugin Author [donmik](https://wordpress.org/support/users/atallos/)
 * (@atallos)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/set-default-on-datepicker/#post-3638639)
 * I tried it and it works for me. Can I see your web ?
 *  Thread Starter [pfrey](https://wordpress.org/support/users/pattyfresonke/)
 * (@pattyfresonke)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/set-default-on-datepicker/#post-3638667)
 * I figured out how to get it to work, thanks for all your help!
 *  Plugin Author [donmik](https://wordpress.org/support/users/atallos/)
 * (@atallos)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/set-default-on-datepicker/#post-3638669)
 * And how do you get it to work ? It will be helpful to know if anyone has the 
   same problem in the future.
 * Thanks!
 *  Thread Starter [pfrey](https://wordpress.org/support/users/pattyfresonke/)
 * (@pattyfresonke)
 * [13 years, 1 month ago](https://wordpress.org/support/topic/set-default-on-datepicker/#post-3638673)
 * It was just a typo on my part.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Set default on datepicker’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/buddypress-xprofile-custom-fields-
   type.svg)
 * [Buddypress Xprofile Custom Fields Type](https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/)
 * [Active Topics](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/buddypress-xprofile-custom-fields-type/reviews/)

 * 10 replies
 * 2 participants
 * Last reply from: [pfrey](https://wordpress.org/support/users/pattyfresonke/)
 * Last activity: [13 years, 1 month ago](https://wordpress.org/support/topic/set-default-on-datepicker/#post-3638673)
 * Status: resolved