Welcome to WebmasterWorld Guest from 184.73.112.180

Forum Moderators: lorax & rogerd

Saving Options From a Dropdown Selection on an Admin Options Page

I'm trying to get a submit button to save my data on a wordpress admin opti

   
8:33 pm on Nov 3, 2012 (gmt 0)

10+ Year Member



I'm trying to create my first plugin and have gotten as far as creating the options admin page, adding it to the menu, showing a drop down box and showing a submit button.

Howsomever, I cannot get the form to save the value, or update an existing option.

As a non-coder, I have gotten myself lost trying to understand the codex and the api, including being unable to copy and paste the options page examples that are shown and make them work.

If you can help me, please, please jump right in and tell me what to do. Here's what I have for a form so far ...

// Plugin title and some other stuff

?>
<!-- Opening The Form -->
<div>
<form method="post" action="options.php">

<?php
settings_fields( 'products' );
?>

<!-- Inserting The Dropdown Box On The Page And Inside The Page Function -->
<!-- Using selected() instead -->
<select name="options[products]">
<option value="unicykes" <?php selected( $options['products'], unicykes ); ?>>unicykes</option>
<option value="bikes" <?php selected( $options['products'], bikes ); ?>>bikes</option>
<option value="trikes" <?php selected( $options['products'], trikes ); ?>>trikes</option>
</select>

<?php
do_settings_fields( 'products' );
?>
<p>
<input type="submit" value="<?php _e( 'Save Options', 'products' ); ?>" />
</p></form>
</div>

<?php
}

// End of page
?>
 

Featured Threads

Hot Threads This Week

Hot Threads This Month