-2

I am doing a plugin tutorial, but it was made for wordpress v2.something.

The problem is - when I go to admin menu, under Settings - I get a notice error =>

has_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead. in C:\wamp\www\jw\wp-includes\functions.php on line 3017

This is the relevant code:

<?php

if ( ! class_exists('SBC_Admin') ) {

    class SBC_Admin {

        function add_config_page() {

            if ( function_exists('add_submenu_page') ) {
                add_options_page(
                    'Seach by Category Options',
                    'Search by Category',
                    10,
                    basename(__FILE__),
                    array('SBC_Admin', 'config_page')
                );
            }
        }

        function config_page() {
            if ( isset($_POST['submit']) ) { // we're updating options

            }?>
            <div class="wrap">
                <h2>Search by category options</h2>
                <form action="" method="post" id="sbc-config">

                </form>
            </div>
            <?php
        }

    }

}

// insert into admin panel
add_action('admin_menu', array('SBC_Admin', 'add_config_page'));

?>
  • 1
    What have you done to research/debug this issue? The only WordPress function you're calling is add_options_page(). Have you researched add_options_page() in the Codex to try to identify the problem? – Chip Bennett Nov 24 '13 at 14:05
  • Yes. using numbers for permissions is deprecated, so I tried 'Administrator' (because I saw that on the add_options_page page) and it didn't work, and then I saw somewhere else I could use 'administrator' (lowercase a), but options to use were not stated specifically on the add_options_page page – Ollicca Mindstorm Nov 24 '13 at 21:13
  • Why the downvote? The question is well stated and clear. I am new to WP and didn't understand the message completely. – Ollicca Mindstorm Nov 24 '13 at 21:49
4

The deprecated notice is pretty clear:

Usage of user levels by plugins and themes is deprecated. Use roles and capabilities instead.

The only place you use a user level it here:

add_options_page(
    'Seach by Category Options',
    'Search by Category',
    10,
    basename(__FILE__),
    array('SBC_Admin', 'config_page')
);

See that "10"? Don't do that. Use a role, such as "administrator", or a capability instead, just like the message states.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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