How to get the value of input hidden html from text editor to custom page template?

I have 10 or more input hidden in 10 or more pages with different values in Wordpress text editor and I want to get the value using $_POST in a custom page template. How to do this? I tried to called the input hidden name in my custom page template but the value is not getting. Text editor <form method="POST"> <input type="hidden" name="segment" value="test"/> </form> Custom page template $segment = isset($_POST['segment']) ? $_POST['segment'] : '';
Category: Web

Create a custom calculator in wordpress

I am new to Stack exchange as well as Wordpress. So I don't know if i am in right place asking this question. I am writing a technical blog on my wordpress site and in that blog i want to include a custom calculator where users on entering values of 3 mentioned variables, the calculator will predict the outcome of the dependent variable. Suppose for example Y = 5X + 4T. I want to build a calculator in my blog …
Category: Web

How to Fix Form elements do not have associated labels in Wordpress Search Form (without button)

Is there any way to fix the "Form elements do not have associated labels" issue in WordPress search form without having the search button. Google Light House Audit: Form elements do not have associated labels. Labels ensure that form controls are announced properly by assistive technologies, like screen readers. Failing Elements input <input type="text" value="Search" name="s" id="psf" onblur="if (this.value == '') {this.value = 'Search';}" onfocus="if (this.value == 'Search') {this.value = '';}"> I want to add a label in the form …
Category: Web

wp_remote_post and form post

Actually it is more general question but now i am trying to use it on wordpress site so I preferred to post it here. I am trying to understand the difference between remote post and form post. When I query a string and post it to remote server, I get the result as string and with "print $response" see it on browser console. But I want it to be displayed as html on browser. Am I expecting wrong thing or …
Category: Web

Using Ajax to submit a form, and run a SQL Select query based on user input from the form

I'm creating a web form on my WordPress powered website. The form is intended to allow the user to enter a ZIP Code (aka postal code). When the user submits the form, the page should query a MySQL table, SELECT the rows which match the search criteria and dispense those values into a table on the same page. Unfortunately, I have been unsuccessful thus far. Per the example I followed, three components are necessary to query a SQL table from …
Category: Web

Post + form + action + results on the same page

I'm trying to put on a post a custom form and, on the same page I'd like to visualize the results of an action on the form. But I'm missing the basics. Essentially I'd like to do something like this. Is it possible? <?php if(isset($_REQUEST['submit_btn'])) { echo "<div>"; $name = $_POST["names"]; echo "</div>"; } ?> <form action="" method="POST"> <input type="text" name="names" id="names"> <input type="submit" value="submit" name="submit_btn"> </form> ADDITION (after the answer from Tejas gajjar): Thank for the answer. Actually I …
Category: Web

Custom forms + Polylang

I am new to Wordpress but I have some knowledge of PHP. I am creating a bilingual site (with Polylang) which has many forms. Some of them are handled by Contact Form 7 but some others have to be custom made. So, the first form I made was quite a disaster - it works but under certain circumstances. In the archives page of a custom post I insert <form method="post" action="<?php echo esc_url( home_url( '/' ) ); ?>"> <input type="hidden" …
Category: Web

Linking form to user meta fields

I currently have my login page set up to allow sign up through google. Immediately after a successful sign up I'm looking to set up a redirect to a form where the user can enter additional details and these are saved within predefined user meta fields. I know how to set up the fields using ACF or Pods. Are there free plugins available which can link a form to the meta fields? I'm fairly new to developing hooks but if …
Category: Web

How to create input page in Wordpress admin panel?

I have never used wordpress before and I'm trying to learn it now, I hope in this forum we can discuss about wordpress more, so I can more understand about it. I have problem, that I want to create a input page for category but this form are located in admin panel. So, how to do it? especially about that steps. Thank so much..
Category: Web

Take input from form and pass it to function using a wp-plugin

Edit: I have fixed my original issue, please skip to the body for my last remaining issue. I need to make a plugin. That displays an input field to the user, takes that input field data and passess it to a php function, and then reloads that page and displays what ever the user has typed in. What I have in my plugin file function testytest($val1,$val2) { return $val1; } function awepop_add_view() { $idPageToTest = 55; if ( isset($GLOBALS["post"]) && …
Category: Web

Use admin-post to submit form data to external database

I am creating a custom form in WordPress to store and send data to an external database. As part of testing, I was successful in creating a form that submitted form data to the external database by having the form refer back to itself upon clicking the submit button. I now would like to leverage WordPress admin-post functionality instead of having the form refer back to itself. I have set up the action hook correctly as I see the $_POST …
Category: Web

Nonce fail after second submit attempt

I am refactoring my plugin that resets the WordPress database tables back to their defaults and came across an issue. The form submission itself works fine. However, after the first submit, and if you do not refresh the page and submit the form again, the nonce seems to fail. Perhaps there is someone that fully understands how nonces work as I am not sure what is causing this. I have the necessary check for wp_nonce_field and check_admin_referer on the administration …
Category: Web

prevent default not stopping page refresh. Passing form information to and from php with ajax in a wordpress site

I have seen a number of methods dating back to about 2011 in order to take a form and have its data posted via ajax.jquery. I have tried a couple and am just getting the page to reload despite using preventdefault functions. I am trying to take data from my form, have the jQuery listen for the form submit by targeting the actual form id and then call a PHP function in order to have that data posted to the …
Category: Web

Add file upload with validation to custom form

I have a custom contact form page that I am trying to add an upload field that validates filesize and filetype. Before adding the validation everything worked. <?php /* Template Name: Contact-Page-with-upload * * A Custom PHP Contact us page. Add or change form fields on line 28 and in the form itself. * Jquery is used to add/remove Bootstrap has-error class to invalid fields. */ /** * Get Error Class * * @return string; */ function getErrorClass($failedKeys, $key) { …
Category: Web

Can you have more than one nonce on a page?

I have a site with a page where there's one form in the sidebar, and one in the main body of the page. The sidebar comes first in the HTML. Both forms have their own nonces (generated with wp_nonce_field) with different $action and $name parameters. The $referrer fields are on. When I submit the second form, I get the usual "Are you sure you want to do this?" message. If I remove the first form, things work correctly. I added …
Category: Web

After form submission want to show success message in the form page

Admin side I submit form to admin-post.php. I want to print success message in the bottom of the form. Iam new in wordpress what i did shown below. admin.php?page=add-products form code <form action="<?php echo admin_url('admin-post.php') ?>" method="post"> <table> <input type="hidden" name="action" value="add_product_from_admin"> <tr><td>Name</td><td><input type="text" name="pr_name" id="pr_name"></td></tr> <tr><td colspan="2" align="center"><input type="submit" name="pr_submit" id="pr_submit" value="Save Products"></td></tr> </table> </form> add_action( 'admin_post_add_product_from_admin', 'add_product_into_data_base' ); function add_product_into_data_base() { //some database operations wp_redirect(admin_url('admin.php?page=add-products&message=success')); }
Category: Web

How to send form values from the script in functions.php and not from the form on my website?

I have a form on my website and depending on if the user check paypal or wire-transfer the form action should always go to functions.php where I have this simple check at the end of the file: if ( isset( $_POST['submitted'] ) && isset( $_POST['post_nonce_field'] ) && wp_verify_nonce( $_POST['post_nonce_field'], 'post_nonce' ) ) { // CODE AFTER SUBMIT HERE } So, my question is how do I do some stuff using an if condition in my functions.php before posting the form …
Category: Web

Custom search to display results within same page

I am using the Easy Digital Downloads plugin to sell my music. I would like to add a custom search form inside the downloads archive page so the results will be displayed on that page. For example, if you'll go to storename.com/downloads and search for 'whatever', you'll find all the songs that contain 'whatever' in their title. So, inside the archive-download.php file I added: <div class="search-in-store"> <form role="search" method="get" id="searchform" class="searchform" action="<?php echo home_url( '/downloads/' ); ?>"> <div> <label class="screen-reader-text" …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.