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

Modifying searchform.php and search.php to have two kinds of searches

For anyone trying to achieve something similar, here’s how I solved it: In searchform.php, duplicate the form, as such: <form method=”get” id=”searchform” action=”<?php echo esc_url( home_url( “https://wordpress.stackexchange.com/” ) ); ?>”> <input type=”text” name=”s” id=”s” placeholder=”<?php esc_attr_e( ‘Search by Post’ ); ?>” /> <input type=”hidden” name=”search-type” value=”posts” /> <button type=”submit” name=”submit” id=”searchsubmit” value=”<?php esc_attr_e( ‘Search’ ); … 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.

Custom form action hook

admin_url( ‘admin-post.php’ ) is the non-ajax version of admin_url( ‘admin-ajax.php’ ) Similar to admin-ajax.php it will fire one of four hooks: Logged out users admin_post_nopriv_{action} ($_REQUEST[‘action’] specified) admin_post_nopriv (no $_REQUEST[‘action’] specified) Logged in user admin_post_{action} ($_REQUEST[‘action’] specified) admin_post (no $_REQUEST[‘action’] specified) The ‘action’ can therefer bespecified as part of the target url (e.g. admin_url( ‘admin-ajax.php?action=my-action’ … Read more

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

Using AJAX to return search form results

There are two issues in your code You need to add script in wp_enqueue_scripts hooks like this – add_action(‘wp_enqueue_scripts’, ‘my_custom_js_script’); function my_custom_js_script() { wp_register_script( ‘ajax-productSearch’, get_template_directory_uri() .’/js/ajax-product-search.js’, array( ‘jquery’) ); wp_enqueue_script( ‘ajax-productSearch’ ); wp_localize_script( ‘ajax-productSearch’,’the_ajax_productSearch’, array(‘ajaxurl_productSearch’ => admin_url(‘admin-ajax.php’))); } The second issue is that, you need to add action argument in your jQuery.ajax data. If … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)