Articles of forms

Saving checkbox/option list status?

my self-made admin panel works just fine, but it doesn’t save values of form inputs. When I type something into textbox and click “save” it is still there after refreshing, thanks to PHP: <input type=”text” name=”header” value=”<?php echo get_option(‘header’); ?>” /> So the PHP echoes its own value to a input and everything is just […]

How to create and work with custom data / tables (i.e., for arbitrary data)?

Getting started on WordPress just today. I noticed that WordPress created tables in a mySql database (with name *.wrdp1) when I first set it up. These tables cover comments, posts, users, and some link-relationships. Now, let’s say I would like to work with a new set of data. Suppose I were to create a page […]

Return to option page after running PHP script

I have an option screen for my plugin, it’s just a simple form. <div class=”wrap”> <h2>SoundCloud Podcast Importer Options</h2> <hr/> <h2>Add a show</h2> <form method=”post” action=”../wp-content/plugins/SCImp-Pro/scimp_add_feed.php”> <p>Feed URL: <input type=”text” name=”scimp_feed_url” /></p> <p>Show Category: <select name=”scimp_show_category”> <?php $categories=get_categories(); foreach ($categories as $category) { ?> <option value=”<?php echo $category->name; ?>”><?php echo $category->name; ?></option> <?php } ?> […]

Reset recaptcha contact form 7

I have multiple forms(contact form 7) in a page and need to reset the recaptcha after the form is submitted via ajax. I checked recaptcha API and it has grecaptcha.reset(); but it resets only first recaptcha in a page. Following is the method to target a specific recaptcha according to recaptcha API: grecaptcha.reset( opt_widget_id ) […]

Performing a POST action on homepage goes to posts page

On every page of my site I got a contact form that will send an email to the respective address. On this site also I’ve set the front page display to a static page. The contact form will basically post to self and if successful will take the user to a new page, otherwise will […]

How Could I sanitize the receive data from this code

<form id=”tellastory” method=”post” action=””> <label for=”fullname”>Full Name </label> <input id=”fullname” name=”fullname” type=”text” maxlength=”255″ value=””/> <label for=”title”>Title </label> <input id=”title” name=”title” type=”text” maxlength=”255″ value=””/> <label for=”title”>Message </label> <textarea id=”editor” name=”editor” rows=”20″ cols=”50″></textarea> <input type=”hidden” name=”form_id” value=”123456″ /> <input id=”saveForm” type=”submit” name=”submit” value=”submit” /> </form> <?php $storyteller_user_id = “3”; //your guest user id here //$stories_category = “3”; […]

submitting form via admin-ajax.php returns 0

Trying to: Submit form using admin-ajax.php to update post data from ‘draft’ status to ‘publish’ status and add custom meta field for filter type. Form contents: <form action=”<?php echo admin_url( ‘admin-ajax.php’ ) ?>” method=”post”> <?php wp_nonce_field( ‘submit_filter’, ‘my_filter_nonce’ ); ?> <div class=”small-6 medium-3 large-3 columns”> <div class=”card”> <img src=”<?php echo get_the_post_thumbnail_url( $posts[0]->ID, ‘thumbnail’ ); ?>” […]

How to handle custom form submission?

I created a theme, in that theme, there is a custom form in the footer, The front end is good, But I don’t know how to handle the back-end of the form submission in WordPress. I mean I could create a handle_form.php in the simple website, Or handle the form on the same page, But […]

How to verify this checkbox is checked?

Actually I want to include a file if the checkbox is checked <?php $checked = get_option(‘automatic’) ? “checked=’checked'” : “”; echo “<input type=’checkbox’ name=’automatic’ $checked />”; ?> if(get_option(‘automatic’) == ‘checked’)) ( require_once ‘myfile.php’; ) This form is in a plugin option page

Settings API erases itself?

I have two forms created using Settings API, and when I save one of them the other one gets erased and vice versa. Here’s the whole code so you could paste it into your functions.php file and see for yourself: // Register settings function registerSettings() { register_setting(‘XX_theme_settings’, ‘XX_theme_settings’ ); add_settings_section(‘theme_options’, ‘Theme Options’, ‘theme_options_generate’, ‘page1’ ); […]