0

I have it where when someone leaves a text field empty in the WordPress admin panel, it will display a admin notice and still save the results to options.php.

I'd like to grab the value of 'insta_id' and use $_POST to retrieve it instead of submitting a blank form field.

Without ID: enter image description here

With ID: enter image description here

How would I make it so that it just returns the previous saved <?php echo get_option('insta_id'); ?> if there is no ID defined?

<!-- Username ID -->
<tr valign="top">
    <th scope="row">
        <?php _e("Username ID", "instagram-enabler"); ?>
    </th>
    <td>
        <fieldset>
            <label for="insta_id">
                <?php if (empty(get_option('insta_id'))): ?>
                    <div class="notice notice-error is-dismissible">
                        <p><?php _e('Please input a Instagram User ID', 'instagram-enabler'); ?></p>
                    </div>
                    <input type="number" name="insta_id" id="insta_id" value="<?php echo get_option('insta_id'); ?>" size="64" class="regular-text code" />
                <?php else: ?>
                    <input type="number" name="insta_id" id="insta_id" value="<?php echo get_option('insta_id'); ?>" size="64" class="regular-text code" />
                <?php endif; ?>
            </label>
            <p class="description">
                <?php _e("Enter the Instagram Business ID", "instagram-enabler"); ?>
            </p>
        </fieldset>
    </td>
</tr>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.