Question

Thanks to Wordpress calling their content 'posts', it makes it hard to find information on dealing with forms submitted with the POST protocol. My question is simple, the answer should be simple to a seasoned Wordpress developer.

Using a Wordpress plugin which has a form in the widget method of the class, I named the variables using the Wordpress get_field_name function. I can't find the corresponding function that determines what $_POST variable to process. I could kludge a solution, but I want to use the Wordpress framework exclusively for this.

I need to maintain the class variable structure so that multiple instances of this widget don't have variable overlap. I could simply set the name and used the widget_id from the args, but that doesn't seem to be the correct way to stay within the framework.

To clarify further, the widget delivers a form for the user side, not the admin side.

Example:

class someWidget extends WP_Widget {
 public function someWidget() {
  $this->WP_Widget('somewidget', __('Some Widget'));
 }

 public function form($instance) {
 }

 public function update( $new_instance, $old_instance ) {
  $instance = $old_instance;
  return $instance;
 }

 public function widget($args, $instance) {
  $before_title = $before_widget = $after_widget = $after_title = '';
  extract($args, EXTR_IF_EXISTS);
  echo $before_widget.$before_title.$instance['WidgetTitle'].$after_title;

  $somewidget_variable = $_POST['????']; // < -- What function retreives the variable?
  if ($somewidget_variable) {
   // amazing stuff
  }
?>
<form method="POST">
<input id="<?php echo $this->get_field_id('somewidget_variable');?>" name="<?php echo $this->get_field_name('somewidget_variable');?>" type="text" value="<?php echo $somewidget_variable;?>" />
<input type="submit" />
</form>
<?php
echo $after_widget;
 }
}

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top