Shortcode Attributes to Return different $_POST


I am creating a solution to enable front end editing of custom fields, I am using hidden input containing the custom field to send via POST request to an editing form, the form contains default value in the form of shortcodes to render the correct $_POST received.

I am using an attribute to choose which $_POST to render in each shortcode, [Edit_Field Field=”Email_1″] should output $_POST for email 1 (Sent from the previous page via post request and hidden input]

function Edit_field($atts){
                  'Field' => '',
               ), $atts));
    if($Field == 'Email_1'){
   return $_POST['Edit_Email_1'];}
   if($Field == 'Client_Description'){
   return $_POST['Edit_Client_Description'];}
add_shortcode('Edit_field', 'Edit_field');

The input HTML:

<input type="hidden" name="Edit_Email_1">Value to be sent</input>  

On the front end I am anticipating to use:

[Edit_Field Field="Email_1"]

Is there anything special for dealing with $_POST in this case?

Many thanks in advance,

, , , , Ali Hamdan 1 year 2020-07-26T12:10:27-05:00 0 Answers 47 views 0

Leave an answer