Support » Plugins and Hacks » WordPress Settings API Tutorial (save issue)

  • Resolved Guido

    (@guido07111975)


    Hi there,

    I’m building a plugin and using this tutorial from Otto to create plugin settingspage:
    http://ottopress.com/2009/wordpress-settings-api-tutorial/

    With this tutorial I’m able to create a plugin settingspage with a single (text) inputfield.

    It’s a great help and everything goes well until I press save > field turns blank again.

    I even tried all of his original code (copy-paste) bit still nothing is saved. Any ideas?

    Guido

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    Helps if you post your code. Nobody can tell you what’s wrong without seeing your code.

    Guido

    (@guido07111975)

    Hi Otto,

    I understand, but because I did not succeed with your original code as well, I thought maybe something changed in WP codex.

    Temp link to my code:
    http://www.webmastergroningen.nl/otto.txt

    Thanks in advance.

    Guido

    Guido

    (@guido07111975)

    Btw, I do notice this in your tutorial:
    <form action="options.php" method="post">

    I don’t have that page since I have everything stored in one page. So I changed that into:
    <form action="" method="post">

    Don’t think that causes my issue (inputfield turns empty after pressing save).

    Guido

    Guido

    (@guido07111975)

    I don’t have that page since I have everything stored in one page. So I changed that into:

    <form action="" method="post">

    I notice it’s calling the options.php from folder wp-admin, so you can ignore last post ;-).

    Guido

    Guido

    (@guido07111975)

    Hi again,

    With another tutorial I got the settingspage working:
    http://kovshenin.com/2012/the-wordpress-settings-api/

    So I guess there was a (small) mistake in my previous code.

    Guido

    Moderator Samuel Wood (Otto)

    (@otto42)

    if(!preg_match('/^[a-z0-9]$/i', $options['text_string'])) {
    	$options['text_string'] = '';
    	}

    Is your text string supposed to only be allowed to be a single letter or number?

    Dunno what you changed, but I’m guessing it was around here somewhere.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘WordPress Settings API Tutorial (save issue)’ is closed to new replies.