Shortcodes are case-sensitive, so you should:
Use
[Edit_field Field="Email_1"]
And not
[Edit_Field Field="Email_1"]
Because you defined the shortcode as add_shortcode('Edit_field', 'Edit_field');
— note the first Edit_field
, where the f
is in lowercase.
Secondly, WordPress converts the shortcode attributes to lowercase, so the $Field
in your case will be undefined and therefore, you should use $field
instead.
However, please just avoid using extract()
and use the $atts
instead to access the shortcode attributes:
function Edit_field( $atts ) {
$atts = shortcode_atts( array(
'field' => '',
), $atts );
if ( $atts['field'] == 'Email_1' ) {
return $_POST['Edit_Email_1'] ?? 'NA';
}
if ( $atts['field'] == 'Client_Description' ) {
return $_POST['Edit_Client_Description'] ?? 'NA';
}
}
Additionally, always check if the POST variable is actually set:
// Example for the Edit_Email_1 variable:
return isset( $_POST['Edit_Email_1'] ) ? $_POST['Edit_Email_1'] : 'NA'; // use this
return $_POST['Edit_Email_1'] ?? 'NA'; // or like I used in the above function, using PHP 7 format