Skip Navigation

[Resolved] populate a cred form date field with today's date

This support ticket is created 4 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 5 replies, has 2 voices.

Last updated by Nigel 4 years, 6 months ago.

Assisted by: Nigel.

Author
Posts
#1357749

Tell us what you are trying to do?
I am trying to populate a cred form date field using the code below when creating a cpt record not updating one. But it does not work.

[cred_field field='csh-create-date2' force_type='field' class='form-control' output='bootstrap' value='[date1]']
I have also tried to create it using a function same problem.

#1357935

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Mario

What value does the custom shortcode date1 provide?

Date fields are stored as UNIX timestamps.

So if you use 1570492800 for the default value, that will show up in the form as 8 Oct 2019, i.e. today's date.

So your custom shortcode to output "today's date" should return the timestamp for today.

Something like this:

add_shortcode( 'today', function(){

    $today = date( 'Y-m-d' );
    $today_timestamp = strtotime( $today );
    
    return $today_timestamp;
});
#1357969

Hi Nigel

I have used the code as suggested:
[cred_field field='csh-create-date' force_type='field' class='form-control' output='bootstrap' value='[today_timestamp]']
but not working.

#1358033

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

If you used my exact code to register the shortcode, then the shortcode is "today", so you would need

[cred_field field='csh-create-date' force_type='field' class='form-control' output='bootstrap' value='[today]']

I had already tested it on my own site, so it should work.

#1358103

Hi Nigel

Thank you that worked.
I am also having a similar problem with trying to populate the email address :

[cred_field field="csh-email-address" value="[types field='s-email'][/types]"]

The email is the logged in author - using the record found in the view cpt seeker

#1358693

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

I don't follow where the email address is coming from, but if you want the email address of the currently logged-in user, you can provide that with the wpv-user shortcode:

[cred_field field="csh-email-address" value="[wpv-user field='user_email']"] 
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.