- Issue created by @rajitha.somarathna
- Assigned to apatel0325
- Status changed to Needs review
over 1 year ago 4:47am 19 April 2023 - 🇮🇳India apatel0325
function mymodule_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'node_article_form') {
// Set the "Publish on" date to tomorrow's date
$form['options']['status']['scheduled']['publish_on']['#default_value'] = date('Y-m-d', strtotime('+1 day'));
}
}@rajitha.somarathna Can you please try with the above code?
This is great.. for do this what is the path for the function? I have no idea to change which place to change the code. @apatel0325
- 🇮🇳India apatel0325
Create new custom module and in .module file you have to write above function.
I'm using the 2.0RC version of Scheduler, and have tried this code in a custom module per your suggestion (in my case, setting the unpublish date to two years in the future).
It isn't working for me. Not sure what I'm doing wrong? Here's the code from my .module file:
function mymodule_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'node_events_form') { // Set the "Publish on" date to two years from now $form['options']['status']['scheduled']['unpublish_on']['#default_value'] = date('Y-m-d', strtotime('+2 years')); } }