0

Sorry for the question but can you help me? I have this form in a widget:

<form> 
 <fieldset>
  <legend>Counter Position:</legend>
  </br>
  <p> 
   Right  <input type="radio" name="position" value="right"/>
  <p>  
   Left  <input type="radio" name="position" value="left"/>
  <p>
   Center  <input type="radio" name="position" value="center"/>
</fieldset>
</form>

how to save on database the option selected?

1
  • is this a form for the widget admin page - or front-end? Commented Apr 27, 2012 at 12:23

1 Answer 1

0
<?php add_option( $option, $value, $deprecated, $autoload ); ?>

http://codex.wordpress.org/Function_Reference/add_option

global $options;
?>
<form action="options.php" method="post">
  <?php $settings = get_option('options');
  ?>
  <?php settings_fields('theme_options'); ?>
    <fieldset>
        <legend>Counter Position:</legend>
        </br>
        <p>
            Right <input type="radio" name="position" value="right"/>
        <p>
            Left <input type="radio" name="position" value="left"/>
        <p>
            Center <input type="radio" name="position" value="center"/>
    </fieldset>
</form>

<?php


function r_set()
{
  register_setting('theme_options', 'options', 'validate_options');
}

add_action('admin_init', 'r_set');
function validate_options($value)
{
  global $sa_options;
  $val['position'] = $value['position'];
  return $val;
}
2
  • thanks, how to use for save the radio selected from users??
    – victor
    Commented Apr 27, 2012 at 11:51
  • check my edit..
    – Mohit Bumb
    Commented Apr 27, 2012 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.