WordPress.org

Forums

[resolved] WordPress Settings API Tutorial (save issue) (7 posts)

  1. Guido
    Member
    Posted 1 year ago #

    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

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

  3. Guido
    Member
    Posted 1 year ago #

    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

  4. Guido
    Member
    Posted 1 year ago #

    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

  5. Guido
    Member
    Posted 1 year ago #

    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

  6. Guido
    Member
    Posted 1 year ago #

    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

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

Topic Closed

This topic has been closed to new replies.

About this Topic