145 posts
  • Has been part of the Envato Community for over 2 years
  • Located in Austria
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
LovelessDesign says

I have to save my post two times to get the variable $event_realstartdate saved. I understand why it is but don’t know how to rewrite it.

I have a textfield “event_startdate”. When the user changes this textfield, it calculates the content of a readonly textfield “event_realstartdate”.

When clicking on Update once, the readonly textfield is calculated correctly but it’s not “transfered”, so that I could use it on my page.

<input type="text" id="event_startdate" name="event_startdate" value="<?php echo $event_startdate; ?>">

<?php include( 'calculation.php' ); $event_realstartdate = $event_startdate; ?>
<input type="text" readonly id="event_realstartdate" name="event_realstartdate" value="<?php echo $event_realstartdate; ?>">
if(isset($_POST['event_startdate'])) {  
        update_post_meta($post_id, 'event_startdate', esc_attr( $_POST['event_startdate']) );
    }    
if(isset($_POST['event_realstartdate'])) {  
        update_post_meta($post_id, 'event_realstartdate', esc_attr( $_POST['event_realstartdate']) );
}    
145 posts
  • Has been part of the Envato Community for over 2 years
  • Located in Austria
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
LovelessDesign says

this reply was nonsense

2122 posts
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Participated in a focus group or interview to improve the user experience on Envato Market
  • Interviewed on an Envato blog
+9 more
revaxarts says

try “disabled” instead of “readonly”

145 posts
  • Has been part of the Envato Community for over 2 years
  • Located in Austria
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
LovelessDesign says

no then it doesn’t work anymore. There’s no problem with readonly.

The problem is that the correct content in the readonly field is only available after saving the first time. After saving the second time, the variable gets the content of the readonly field.

Everything should be done when saving the first time

145 posts
  • Has been part of the Envato Community for over 2 years
  • Located in Austria
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
LovelessDesign says

Any Ideas?

145 posts
  • Has been part of the Envato Community for over 2 years
  • Located in Austria
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
LovelessDesign says

Hi, thank you for helping. I already tried it similar to your version:

if(isset($_POST['event_startdate'])) {  
    update_post_meta($post_id, 'event_startdate', esc_attr( $_POST['event_startdate']) );
        include( 'recurring-calculation.php' ); 
$_POST['event_realstartdate'] = $_POST['event_startdate'];
    update_post_meta($post_id, 'event_realstartdate', esc_attr( $_POST['event_realstartdate']) );    
}    

But I always get this error message when updating the post:

Warning: Cannot modify header information - headers already sent by (output started at C:\iwpserver\htdocs\wordpress\wp-content\themes\eventix\includes\recurring-calculation.php:3) in C:\iwpserver\htdocs\wordpress\wp-includes\pluggable.php on line 881

This error message is only because of the include function. Doesn’t matter what I write in this php file (even if it’s empty). If I remove this include, it would work.

Is there another way instead of posting the whole php file in my metaboxes.php ?

145 posts
  • Has been part of the Envato Community for over 2 years
  • Located in Austria
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
LovelessDesign says

edit.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by