Title: Passing inputted form data to shortcode
Last modified: June 26, 2022

---

# Passing inputted form data to shortcode

 *  Resolved [nathanhkn](https://wordpress.org/support/users/nathanhkn/)
 * (@nathanhkn)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/passing-inputted-form-data-to-shortcode/)
 * I have a form that asks for the name of the profile you want to view then will
   redirect you to a profile page. That profile page is full of shortcode that looks
   like this “[get_sheet_value location=”Kayla!B2″]” Instead of “Kayla” I want it
   to be whatever the user put for the profile name.

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/passing-inputted-form-data-to-shortcode/#post-15770544)
 * The best way IMO would be to alter the passed attribute through the “shortcode_atts_{
   $shortcode}” filter. I’m assuming the shortcode handler uses the related function,
   which most do that accept passed attributes. {$shortcode} in this case would 
   be “get_sheet_value” Your filter callback would get the form value from $_REQUEST
   or similar and alter the appropriate element in the passed array. You’d likely
   want to use logic where the data is only altered if a value is available in $
   _REQUEST, otherwise the value from the shortcode is retained.
    [https://developer.wordpress.org/reference/hooks/shortcode_atts_shortcode/](https://developer.wordpress.org/reference/hooks/shortcode_atts_shortcode/)
 *  Thread Starter [nathanhkn](https://wordpress.org/support/users/nathanhkn/)
 * (@nathanhkn)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/passing-inputted-form-data-to-shortcode/#post-15770626)
 * Thanks! I don’t really know how to do that, but I had another idea. Is there 
   a way that when the form is submitted the name is saved to a variable that is
   accessible by other plugins and on different pages. So instead of passing the
   name through the shortcode, the plugin just gets the variable for the name.
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/passing-inputted-form-data-to-shortcode/#post-15771916)
 * Accessible on different pages means the variable’s value would need to be saved
   in a persistent manner. Variable values normally only persist for the current
   request. The data can be saved somewhere in the DB and accessed by other pages
   as needed. Where to save depends on the nature of the data. A few possibilities
   of many are post or user meta, options, or temporary transients.
 * You will need form handling code that saves the form data somewhere. There are
   several ways to do so. One way is to include such code on the template that outputs
   the form. The form would be set to POST submissions. If the template sees a GET
   request, it outputs the form. If it sees a POST request, it saves the data from
   $_POST to the DB.
 *  Thread Starter [nathanhkn](https://wordpress.org/support/users/nathanhkn/)
 * (@nathanhkn)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/passing-inputted-form-data-to-shortcode/#post-15771919)
 * Okay thanks! Simple question, how would I delete a row in my database, from my
   plugin? I know it’s `$wpdb->delete();` but I don’t what to put for array $where
 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/passing-inputted-form-data-to-shortcode/#post-15774563)
 * Without $where, how would the function know which row to delete?
 * If doing so programmatically were not a requirement, you can manually delete 
   stray, undesired rows through the phpMyAdmin app. Emphasis on “stray”. If the
   deleted row is tied to other data in the DB, it could cause WP to malfunction.
   It’s always wise to make backups before doing anything with phpMyAdmin unless
   you’re absolutely sure you know what you’re doing is completely safe.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Passing inputted form data to shortcode’ is closed to new replies.

## Tags

 * [form](https://wordpress.org/support/topic-tag/form/)
 * [shortcode](https://wordpress.org/support/topic-tag/shortcode/)
 * [variables](https://wordpress.org/support/topic-tag/variables/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 5 replies
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/passing-inputted-form-data-to-shortcode/#post-15774563)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
