homepage Welcome to WebmasterWorld Guest from 23.20.19.131
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / WordPress
Forum Library, Charter, Moderators: lorax & rogerd

WordPress Forum

    
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
calvinmicklefinger




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

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
?>

 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / WordPress
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved