{"id":10908164,"date":"2018-11-22T18:30:00","date_gmt":"2018-11-22T18:30:00","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/adding-new-form-with-email-support\/"},"modified":"2018-11-22T18:30:00","modified_gmt":"2018-11-22T18:30:00","slug":"adding-new-form-with-email-support","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/adding-new-form-with-email-support\/","title":{"rendered":"Adding new form with email support"},"content":{"rendered":"<p>I created a form which will be entered by user<\/p>\n<p>&lt;form id=&#8221;wc-form-return&#8221; action=&#8221;&#8221; method=&#8221;post&#8221;&gt;<br \/>\n  &lt;label&gt;&lt;?php _e(&#8216;Select products for return&#8217;,&#8217;wc_return&#8217;) ?&gt;&lt;\/label&gt;<br \/>\n  &lt;select id=&#8221;wc_products[]&#8221; name=&#8221;wc_products&#8221; class=&#8221;wc_products&#8221; multiple=&#8221;multiple&#8221;&gt;<br \/>\n    &lt;?php<br \/>\n    if ( sizeof( $products ) &gt; 0 ) {<br \/>\n      foreach( $products as $item ) { ?&gt;<br \/>\n        &lt;option value=&#8221;&lt;?php echo $item[&#8216;item_meta&#8217;][&#8216;_product_id&#8217;][0]; ?&gt;&#8221;&gt;&lt;?php echo __(esc_html($item[&#8216;name&#8217;]), &#8216;wc_return&#8217;); ?&gt;&lt;\/option&gt;<br \/>\n      &lt;?php<br \/>\n      }<br \/>\n    }<br \/>\n    ?&gt;<br \/>\n  &lt;\/select&gt;<br \/>\n  &lt;small&gt;&lt;?php _e(&#8216;You can select multiple by holding down the CMD or Ctrl key.&#8217;,&#8217;wc_return&#8217;); ?&gt;&lt;\/small&gt;<br \/>\n  &lt;textarea name=&#8221;wc_message&#8221; id=&#8221;wc_message&#8221; cols=&#8221;30&#8243; rows=&#8221;10&#8243; placeholder=&#8221;&lt;?php _e(&#8216;Explain the reasons for your return&#8217;, &#8216;wc_return&#8217;) ?&gt;&#8221;&gt;&lt;\/textarea&gt;<br \/>\n  &lt;input type=&#8221;hidden&#8221; name=&#8221;order&#8221; value=&#8221;&lt;?php echo $order-&gt;id; ?&gt;&#8221; \/&gt;<br \/>\n  &lt;input type=&#8221;hidden&#8221; name=&#8221;customer&#8221; value=&#8221;&lt;?php echo $order-&gt;billing_email; ?&gt;&#8221; \/&gt;<br \/>\n  &lt;input type=&#8221;text&#8221; name=&#8221;phone&#8221; id=&#8221;wc_phone&#8221; value=&#8221;&lt;?php echo $order-&gt;billing_phone; ?&gt;&#8221; \/&gt;<br \/>\n  &lt;input type=&#8221;checkbox&#8221; name=&#8221;check1&#8243; value=&#8221;Yes&#8221; required&gt;Accept our <a href=\"https:\/\/\"> return and exchange policy <\/a> &lt;\/br&gt;<br \/>\n  &lt;input type=&#8221;submit&#8221; name=&#8221;submit&#8221; value=&#8221;&lt;?php _e(&#8216;Submit&#8217;,&#8217;wc_return&#8217;); ?&gt;&#8221; \/&gt;<br \/>\n&lt;\/form&gt;<br \/>\nIt will be entered by user and we will be sent to given email (that is already setted up)<\/p>\n<p>Now to give these information in email i used<\/p>\n<p>$note_form_email = &#8221;;<br \/>\n    if ( $_POST[&#8216;wc_message&#8217;] != &#8221; ) {<br \/>\n      $note .= &#8216;&lt;br&gt;&lt;br&gt;&#8217;;<br \/>\n      $note .= &#8216;&lt;p&gt;&#8217;.__(&#8216;And the explanation:&#8217;, &#8216;wc_return&#8217;).'&lt;\/p&gt;&#8217;;<br \/>\n      $note_form_email .= &#8216;&lt;p&gt;&#8217;.__(&#8216;And the explanation:&#8217;, &#8216;wc_return&#8217;).'&lt;\/p&gt;&#8217;;<br \/>\n      $note .= apply_filters( &#8216;the_content&#8217;, $_POST[&#8216;wc_message&#8217;] );<br \/>\n      $note_form_email .= apply_filters( &#8216;the_content&#8217;, $_POST[&#8216;wc_message&#8217;] );<br \/>\n      $note .= &#8216;&lt;p&gt;&#8217;.__(&#8216;Customer details:&#8217;, &#8216;wc_return&#8217;).'&lt;\/p&gt;&#8217;;<br \/>\n      $note_form_email .= &#8216;&lt;p&gt;&#8217;.__(&#8216;Customer details:&#8217;, &#8216;wc_return&#8217;).'&lt;\/p&gt;&#8217;;<br \/>\n      $note .= &#8216;&lt;p&gt;&#8217;.__(&#8216;Customer phone:&#8217;,&#8217;wc_return&#8217;).'&lt;\/p&gt;&#8217;;<br \/>\n      $note_form_email .= &#8216;&lt;p&gt;&#8217;.__(&#8216;Customer phone:&#8217;,&#8217;wc_return&#8217;).'&lt;\/p&gt;&#8217;;<br \/>\n      $note .= apply_filters(&#8216;the_content&#8217;, $_POST[&#8216;wc_phone&#8217;] );<br \/>\n      $note_form_email .= apply_filters(&#8216;the_content&#8217;, $_POST[&#8216;wc_phone&#8217;] );<br \/>\n    }<br \/>\nBut output was like this<\/p>\n<p>And the explanation:<br \/>\nHuhhh (written by user on wc_message)<br \/>\nCustomer details:<br \/>\nCustomer phone:<\/p>\n<p>That &#8216;Huhhh&#8217; was written by user on wc_message. He also wrote wc_phone but it was not showing in email. Wc_message is working properly but wc_phone isnt. What am i doing wrong?<\/p>\n","protected":false},"template":"","class_list":["post-10908164","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/10908164","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/10908164\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=10908164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}