Solved

Wordpress Plugin Doesn't Save Options

Posted on 2010-09-21
1
729 Views
Last Modified: 2012-05-10
I am working through the Wordpress Bible, and as usual, a programming book has errors in the code.

This code is ridiculously simple (supposedly); however, it doesn't save anything to the database.

here's the issue:

The plugin load fine.
It activates fine.
It displays the menu fine
But if you enter in the data to be saved to the DB, it doesn't save it.

I know the problem is that the add_action() is the failure point (specifically, because it specifies load-copyright-notices.php as the hook, which is not a hookable function / action).

The issue is... I don't know how to fix it.

How do I fix this?
<?php
/*
Plugin Name: Copyright Notices
Plugin URI: http://emmense.com/copyright-notices/
Description: A plugin that allows the user to set Copyright text in the
theme and control it from WordPress Admin.
Author: Aaron Brazell
Version: 1.0
Author URI: http://technosailor.com/
*/

function copyright_notices_admin()
{
?>
<div class="wrap">
<?php screen_icon(); ?>
<h2>Copyright Notices Configuration</h2>
<p>On this page, you will configure all the aspects of this plugins.</p>
<form action="" method="post" id="copyright-notices-conf-form">
<h3><label for="copyright_text">Copyright Text to be inserted in the footer of your theme:</label></h3>
<p><input type="text" name="copyright_text" id="copyright_text" value="<?php echo esc_attr( get_option('copyright_notices_text') ) ?> " /></p>
<p class="submit"><input type="submit" name="submit" value="Update options &raquo;" /></p>
<?php wp_nonce_field('copyright_notices_admin_options-update'); ?>
</form>
</div>
<?php
}
function copyright_notices_admin_page()
{
        add_submenu_page('options-general.php','Copyright Notices Configuration', 'Configure Copyright Notices ', 'manage_options', 'copyright-notices', 'cop
}

function save_copyright_notices()
{
        if( check_admin_referer('copyright_notices_admin_options-update'))
        {
                if( update_option( 'copyright_notices_test', stripslashes( $_POST['copyright_text']))) wp_redirect( __FILE__ . '?updated=1');
        } else {
                echo "<p>Update fail.</p>";
        }
}
add_action('admin_menu', 'copyright_notices_admin_page');
add_action('load-copyright-notices.php','save_copyright_notices');
?>

Open in new window

0
Comment
Question by:DrDamnit
1 Comment
 
LVL 17

Accepted Solution

by:
jrm213jrm213 earned 500 total points
ID: 33728438
from: http://wordpress.org/support/topic/wordpress-bible-example

if(isset($_POST['copyright_text']))
add_action( 'load-plugins_page_copyright-notices', 'save_copyright_notices' );
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

First things first, I say this in many of my articles, but in this one you can take it as fact. I am not in any way an expert when it comes to WordPress. I am strictly a user. I don't know the programming languages involved, and although I could pro…
SEO can be a real minefield to navigate, but there are three simple ways to up your SEO game just be re-assessing your content output.
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…
The viewer will learn how to count occurrences of each item in an array.

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question