WordPress.org

Ready to get started?Download WordPress

Forums

has_cap was called with an argument that is deprecated (13 posts)

  1. LaneLGD
    Member
    Posted 4 years ago #

    Is anyone else getting this notice:

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

    I get this notice all over the place!

  2. esmi
    Forum Moderator
    Posted 4 years ago #

    You have an out-dated plugin.

  3. henrik_e
    Member
    Posted 4 years ago #

    Configurable Tag Cloud (CTC) caused this message for me while using the latest nightly build.

  4. cmunns
    Member
    Posted 4 years ago #

    Hey you guys is this only a plug-in related issue? I deleted all plug-ins and still have the problem. There is a hard-coded twitter plug-in but I also deleted all references to that as well...

    Thoughts? Original post here:
    http://wordpress.org/support/topic/debug-errors-from-wp-includes?replies=1

    I can't seem to find information anywhere.

  5. kbudiarto
    Member
    Posted 3 years ago #

    Make sure to turn off your debug mode in your wp-config.php file. To do this, edit your wp-config.php in your wordpress root folder. Go to the line that says (around line 81):

    define('WP_DEBUG', true);

    and change it to:

    define('WP_DEBUG', false);

    You should do this for your production site.

  6. barthulley
    Member
    Posted 3 years ago #

    Thanks Kbudiarto - this was driving me nuts - almost every slightly poorly coded plug-in was causing havoc ... and all I had to do was switch off the debug!

  7. dudesl
    Member
    Posted 3 years ago #

    Make sure to turn off your debug mode in your wp-config.php file. To do this, edit your wp-config.php in your wordpress root folder. Go to the line that says (around line 81):

    define('WP_DEBUG', true);

    and change it to:

    define('WP_DEBUG', false);

    You should do this for your production site.

    this solution only disables error/debug messages but does not solve the wordpress error.

    I have this problem with a plugin and a template I'm developing and I think it's an incompatibility problem with some functions like get_options but can not find a similar function for wordpress 3.0. Perhaps the functions are well used, but not the parameters that are happening to them.

    If anyone has an answer or an idea of how to solve it, please let us know.

    Greetings from Argentina!

  8. dudesl
    Member
    Posted 3 years ago #

    Hey! I think I found the answer.

    It seems to be a problem with defining roles and capabilities WordPress.

    When we register a new user can define their roles (Admin, Super Admin, Editor, Contributor, Subscriber). Each of these roles has different skills (reading a page / post, edit a page / post, add a page / post, etc). To learn more about the roles and capabilities provided useful wordpress codex: http://codex.wordpress.org/Function_Reference/add_menu_page

    If we have a plugin or template that generates a new menu in our back end functions such as safely used add_theme_page, add_menu_page, add_submenu_page.

    Consider the statement of one of these functions
    <? Php add_menu_page ($ page_title, $ menu_title, $ capability, $ menu_slug, $ function, $ icon_url, $ position);?>

    The third parameter, $capability, accepts as a value that defines the different capabilities WordPress. This menu give access to only users (roles) that have that capability.

    The error in question is generated because we do not pass a value of type capacity, we offer a value of type User Level, the old system to limit user roles.

    IMPORTANT: The user levels ceased to be used in W 2.0 and W3.0 were completely eliminated. Read more here: http://codex.wordpress.org/User_Levels

    In case you do not understand much I'm posting a link which helped me to understand that this was the problem: http://tumbledesign.com/fix-notice-has_cap-was-called-with-an-argument-that-is- deprecated-since-version-2-0-in-wordpress /

    Hey! I feel good! I solved my problem!

    The autor of this solution is Nicky Hajal. Here, is blog

    pd: sorry for my English, I'm Argentine and not write in English, I do it with google translator

  9. markp_2000
    Member
    Posted 3 years ago #

    I still had issues after I updated the suggested items. I ran a grep command to locate the remain issues.

    I used this command and five other plugins had the same issue as well.

    grep -r "add_[a-zA-Z].*_page.*, [0-9]," .

    I used the table at the bottom of http://codex.wordpress.org/Roles_and_Capabilities#User_Level_to_Role_Conversion to figure out the right string value.

  10. Andy Potanin
    Member
    Posted 3 years ago #

    Using a numeric setting for the capability setting in add_submenu_page() pages causes this error.

    Example, using 10 versus 'manage_options' will cause this notice.

  11. aradams
    Member
    Posted 3 years ago #

    I've come across this error in many plugins. Sometimes reporting the error to the plugin developer will help them to be aware of issues that should be addressed to keep the plugin up-to-date. Debug should never be used for production sites but it's really helpful in development.

  12. heather.m
    Member
    Posted 3 years ago #

    Thanks Dudesl! Your research and explaination was exactly what I needed. :)

  13. treydock
    Member
    Posted 3 years ago #

    Andy Potanin's response is spot on. A plugin I'm working on was using "10" so changed it to "manage_network". Thanks!!

    Also markp_2000, I couldn't get your yours to work, because the [0-9] wasn't picking up the '10' in my instance. This is what I used...

    grep -HnR "add_[a-zA-Z].*_page.*, [0-9]*," ./

    I not very good with regex the additional astrick might be the best solution, but I ran that on my plugins directory and found 11 plugins using the old numeric role identifier :-/ .

    - Trey

Topic Closed

This topic has been closed to new replies.

About this Topic