Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When writing plugins, it's a good idea to keep your data-handling within the plugin's main file (i.e. not sending it to a separate file), and activate functions to handle it accordingly. Basically, you can set your form's action to point to either the plugin's file, or the page that contains the form.</p> <p>Let’s assume this form you are working on is displayed on the front end of the site, on the sidebar. To handle data coming from that form when a user clicks “submit”, you could create a function in our plugin's file such as:</p> <pre><code>function $csf_get_data(){ global $wpdb; //since your this function is in your plugin’s file, $wpdb should be available, so no errors here! =) $csf_selected_sport = $_POST['csf_radiobutton_group_sport']; $csf_db_table = $wpdb-&gt;prefix . "activity"; $csf_data = $wpdb-&gt;get_results($wpdb-&gt;prepare(" SELECT * FROM " .$csf_db_table. " WHERE " . $csf_selected_sport ." ")); //do your stuff with $csf_data } //now run it everytime the plugin is run if(isset($_POST[‘submit’])){ $csf_get_data(); } </code></pre> <p>Now, you can set up your form action’s property to send the data to the same page, which will be able to handle it using the function above. You could use either:</p> <pre><code> action=”” </code></pre> <p>or</p> <pre><code> action="&lt;?php the_permalink()?&gt;" </code></pre> <p>Please note: to make sure the data is coming from your site (especially public forms), remember to use wp_nonce_field() to create a nonce field that can be validated byt wordpress via wp_nonce(): <a href="http://codex.wordpress.org/Function_Reference/wp_nonce_field" rel="noreferrer">http://codex.wordpress.org/Function_Reference/wp_nonce_field</a></p> <p>Hope that helps,</p> <p>Vq.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload