Problem: In my Form, I would like to include a select field with options for each Country, so Users can select their Country of origin when registering for the site.
Solution: Toolset does not include built-in Country select fields, but another User has created a module that includes information for importing such a field. You may import information from that module as a starting point.
Problem: After two days have passed from the time of post creation, I would like to display some text on my post that says the post has expired.
Solution: Use two separate custom date fields to store the post creation timestamp and the post expiration timestamp. Use a custom function or custom shortcode to compare the expiration timestamp with the current timestamp. The following code example shows how to set the two requested custom field values:
//FECHA AUTOMÁTICA BONOS
add_action( 'save_post', 'tssupp_auto_set_date_fields', 100, 3 );
function tssupp_auto_set_date_fields( $bonos, $post, $update ) {
$post_type = 'bonos';
$created_field_slug = 'fecha-de-creacion-del-bono'; // edit your created field slug here
$expiration_field_slug = 'fecha-de-caducidad'; // edit your expiration field slug here
// do not edit below this line
$created_field_value = get_post_meta($bonos, 'wpcf-' . $created_field_slug, true);
$expiration_field_value = get_post_meta($bonos, 'wpcf-' . $expiration_field_slug, true);
if ( $post->post_status == 'publish' && $post->post_type == $post_type && !$created_field_value ) {
update_post_meta( $bonos, 'wpcf-' . $created_field_slug, date('U') );
}
if ( $post->post_status == 'publish' && $post->post_type == $post_type && !$expiration_field_value ) {
update_post_meta( $bonos, 'wpcf-' . $expiration_field_slug, (date('U') + 172800) );
}
}