• Resolved mmoser

    (@mmoser)


    I’m trying to save some plug-in options with no luck. First, the option is not even being added with the default and when I click save it just takes me to options.php. Any idea what I’m missing?

    add_action("admin_init","tvc_globals_init");
       function tvc_globals_init(){
        register_setting("tvc_globals", "tvc_global_main");
        }
      register_activation_hook( __FILE__, 'tvc_globals_activate' );
      function tvc_globals_activate(){
        add_option("tvc_global_main", "my_default");
        }
      add_action('admin_menu', 'tvcweb_admin_actions');
      function tvcweb_admin_actions(){
        add_options_page("TVC Globals", "TVC Globals", 10 , __FILE__ , "tvc_global_admin");
        }
      function tvc_global_admin(){
        register_setting("tvc_globals", "tvc_global_main");
        $tvc_main = get_option("tvc_global_main");
        print "<div class=\"wrap\">
        <h2>TVCWeb Global Settings</h2>
        <form method=\"post\" action=\"options.php\">". settings_fields("tvc_globals") ."
          <div class=\"form-table\">
            <p>site root<br />
              <input name=\"tvc_global_main\" type=\"text\" value=\"$tvc_main\" />
              </p>
          </div>
          <p class=\"submit\"><input type=\"submit\" class=\"button-primary\" value=\"".__("Save Changes")."\" /></p>
        </form>
        </div>";
        }
Viewing 1 replies (of 1 total)
  • Thread Starter mmoser

    (@mmoser)

    I believe I’ve figured out my problem. It’s the way I was calling settings_fields().

    Many thanks to the sample provided at planetozh

    Sticking to his code formatting this is now working for me. Once I try to build and print one long string again, I’m back to the broken behavior.

Viewing 1 replies (of 1 total)
  • The topic ‘saving plugin options – settings_fields()’ is closed to new replies.