$_POST empty on submit (same code, same form submits normally on local server)

The best way to deal with Form Posts in WordPress is to use a special endpoint, /wp-admin/admin-post.php. POST data can be messed up, both by the WP Query call, and by any redirects that happen. So you set up your form with this action: <form action=”<?= admin_url(‘admin-post.php’) ?>” method=”post”> <input type=”hidden” name=”action” value=”special_action”> <?php wp_nonce_field(‘special_action_nonce’, … Read more

Built-in data validation function for URLs

Use esc_url( $url ) for URLs that should be displayed and esc_url_raw( $url ) if the URL should be sent to the database. The first will replace bare ampersands & with &#038;. The second is a wrapper for the first; it will just suppress the escaping of ampersands. Both functions will check the protocol. See … Read more

How to update selective options on plugin settings page

First kick in your validation callback by changing the register_setting() to register_setting( ‘pluginname_options’, ‘pluginname-settings’, ‘pluginname_validate’ ); And then update your validation function to actually do something. Below it gets the current state of the options, and then only updates the pieces of the array that are submitted. When you are on a tab and click … Read more

Placeholders in Jetpack Contact Form [closed]

You can do this by means of jQuery (which means this is rather a jQuery/JavaScript question). Put the following in one of your (already included) JS files, or create a new JS file and enqueue it, or hard-code it in between <script>…</script> tags: jQuery(document).ready(function($) { $(‘#my-form-field’).attr(‘placeholder’, ‘Please enter your name…’); });

recommended practice for form submission

I would use init hook in your plugin file to register custom function add_action( ‘init’, ‘custom_proccess_form’ ); And then check form inputs in the custom function, you mentioned creating posts function custom_proccess_form() { $wp_error = true; // report errors or not $nonce = $_POST[‘_wpnonce’]; if( isset($_POST[‘insert_post’]) && wp_verify_nonce($nonce, ‘my-nonce-name’) ) { $post = array( ‘post_title’ … Read more

Wp_mail Returning False on Server

Your code looks okay to me. Instead check whether email working in other part of the website or not!! Use Postman SMTP Mailer/Email Log plugin to configure / test / debug your mail system.

need to add attach thumbnail from my form

Its pretty simple actually. Here is the link for the set_thumbnail function reference codex. And here is the answer for the file upload. First off all you have to attach the file to the post : function attach_uploads($uploads,$post_id = 0){ $files = rearrange($uploads); if($files[0][‘name’]==”){ return false; } foreach($files as $file){ $upload_file = wp_handle_upload( $file, array(‘test_form’ … Read more