Forums

Restrict Categories
[resolved] Error when using plugin... (23 posts)

  1. Peja
    Member
    Posted 1 year ago #

    I get this for every category on the edit screen.

    Warning: in_array() [function.in-array]: Wrong datatype for second argument in /home/mysite/public_html/wp-content/plugins/restrict-categories/restrict-categories.php on line 204

  2. Matthew Muro
    Member
    Posted 1 year ago #

    Some have reported that selecting a category and saving fixes this.

    If not, I'm working on some updates and will hopefully get them released soon.

  3. misthero
    Member
    Posted 1 year ago #

    exact same problem here just after installing the plugin the very first time on a new wordpress site.

    the error is shown next to every unchecked checkbox, if you chack it the error is gone for that checkbox, anyway the plugin doesn't work. No category is restricted.

    Thank you for the support

  4. Matthew Muro
    Member
    Posted 1 year ago #

    I just pushed out Version 1.3 that hopefully fixes this error.

    @misthero: can you provide me the PHP version you are running (eg. 5.2.1, 5.3.2)?

  5. misthero
    Member
    Posted 1 year ago #

    Thank you for your answer,

    I just udpdated but:

    Downloading update from http://downloads.wordpress.org/plugin/restrict-categories.1.3.zip…
    
    Unpacking the update…
    
    Installing the latest version…
    
    Deactivating the plugin…
    
    Removing the old version of the plugin…
    
    Plugin upgraded successfully.
    
    Reactivating the plugin…
    
    Warning: Invalid argument supplied for foreach() in /home/www/test-site/public_html/wp-content/plugins/restrict-categories/restrict-categories.php on line 277

    I see this error on top of every page in the dashboard now....

    PHP Version 5.2.6-1+lenny9

    I tried to disable every plugin but restrict categories, no good.

    anyway the previous error is gone, still no gategory restricted.

    Thank you again.

  6. Matthew Muro
    Member
    Posted 1 year ago #

    Hmm...

    You shouldn't be getting an error on that line. The only reason you'd be getting that error is if get_user_meta is not returning an array.

    Can you add var_dump($user_cap); right before line 277 and tell me what it outputs?

    Also, you may want to download a fresh copy of the plugin again.

  7. misthero
    Member
    Posted 1 year ago #

    Tis is what I get adding that line

    string(0) ""
    Warning: Invalid argument supplied for foreach() in /home/www/test-site/public_html/wp-content/plugins/restrict-categories/restrict-categories.php on line 279

    Like I said is a fresh installation with untouched wordpress running Twentyten theme, I'll try deleting and uploading the plugin manually and let you know what happens.

  8. misthero
    Member
    Posted 1 year ago #

    ok, deleted the plugin , uploaded again via ftp and activated, the error is still there...

    If you want me to try anything else I'm here.

    Thank you again

  9. Matthew Muro
    Member
    Posted 1 year ago #

    For some reason, get_user_meta is returning an empty string. What version of WordPress are you running?

  10. misthero
    Member
    Posted 1 year ago #

    oh sorry, I went to sleep, the wordpress version is the last, 3.0.1 english languange, the theme is twentyten,it is a test server, I'm testing some functionalities I want to include in a real theme, if it's important the istallation for now includes just 6 users I created for testing a 2 categories.

    if you want I can give you access to the dashboard, no problem for me if you have some spare time..

    Thank you.

  11. Matthew Muro
    Member
    Posted 1 year ago #

    How comfortable are you with MySQL?

    If you can use phpMyAdmin or something similar to access your database, open the wp_usermeta table and find the wp_capabilities entries under the meta_key column. You should have one for each user role. Paste in one of the meta_value here. It'll look something like this: a:1:{s:13:"administrator";s:1:"1";}

  12. misthero
    Member
    Posted 1 year ago #

    Hi Matthew,

    I have 2 roles set up right now, the meta values are:

    a:1:{s:13:"administrator";s:1:"1";}
    for the default admin

    a:1:{s:11:"contributor";s:1:"1";}
    for the 6 contributors i created

    but now looking at the database one thing maybe you should know, in this database the prefix is not "wp_" many of us change the default table prefix inside config.php file

    in my case the prefix is "test_" because I specified the var:
    $table_prefix = 'test_';
    in config.php

    so I do not have wp_usermeta nor wp_capabilities but
    but test_usermeta and test_capabilities, and so on...

    Could this be the problem with the plugin??

    Thank you.

  13. Matthew Muro
    Member
    Posted 1 year ago #

    Is the meta_key called wp_capabilities?

  14. Matthew Muro
    Member
    Posted 1 year ago #

    I'm sorry, I should have read your response more carefully.

    Yes, that seems to be the problem with the plugin on your server. I'm able to reproduce the error.

    A short term fix will be to change line 275 from $user_cap = get_user_meta( $current_user->ID, 'wp_capabilities', true ); to $user_cap = get_user_meta( $current_user->ID, 'test_capabilities', true );.

    I will work on getting a permanent fix online if you want to wait for the official download, though.

  15. misthero
    Member
    Posted 1 year ago #

    nope, is test_capabilities

    as a side note I tried the bad way :p

    changing any istance of wp_capabilities in the plugin with test_capabilities, the plugin seem to start working, it restrict categories, but I get another error:

    Warning: Invalid argument supplied for foreach() in /home/www/test-site/public_html/wp-content/plugins/restrict-categories/restrict-categories.php on line 280

    Line280:
    foreach ( $settings[$key . '_cats'] as $category ) {

    maybe mine is not the best solution...

    edit: sorry I wrote while you where posting

  16. Matthew Muro
    Member
    Posted 1 year ago #

    Cool.

    I pushed out a fix for that other error you are getting yesterday right around the time I told you to grab a fresh copy. You may want to try that again and reapply the test_capabilities fix.

    Sorry for all the trouble, but you are helping make it a better plugin :)

  17. misthero
    Member
    Posted 1 year ago #

    oh it works! I redownloaded and applied the fix, the plugin now seem to work as intended.

    You have not to be sorry since you are here giving us your support, this make the plugin already better than others where developers never answer :)

    as a side note, just to know, is it normal that if I check the default wordpress category "Uncategorized" for any role, all the roles below get every category checked?

    I'm very grateful you helped me with this, if anything I can do to help with the plugin... I know css very well, or if you need something like translating it to Italian or Spanish you can contact me.

    Thank you!

  18. Matthew Muro
    Member
    Posted 1 year ago #

    No, that's not normal behavior.

    What browser and operating system are you on?

  19. misthero
    Member
    Posted 1 year ago #

    windows 7 and xp under virtual machine

    Since I am web designer I have many browsers installed to test cross-browser compatibility, anyway I normally surf the internet on firefox..

    edit: I checked and it happens on ie, firefox, chrome and safary

  20. misthero
    Member
    Posted 1 year ago #

    here is a screenshot:

    http://img802.imageshack.us/i/20543152.jpg/

    I checked only the category "Uncategorized" for the Editor, once I saved every other category for the roles below get checked and I have to manually remove the check and save again

    is not a big issue anyway.. :)

  21. Matthew Muro
    Member
    Posted 1 year ago #

    It's not limited to browser or OS. From testing, it looks like my "fix" for the error the original poster broke the logic for the check boxes.

    You can try replacing lines 213-218 with the follow and see if it works.

    if ( is_array($settings[ $id ]) && in_array( $option, $settings[ $id ] ) )
    $checked = 'checked="checked"';
    else
    $checked = '';

    I don't get any errors with this on PHP 5.2 or 5.3, so I'm hoping this is the "real" fix.

  22. misthero
    Member
    Posted 1 year ago #

    yes! that worked, the strange behavior is gone, and no error is showing, categories are being restricted, everything seems perfect now.

    I'll continue working on this site on the next days and will continue testing your plugin, I'll let you know if something else appear.

    Thank you again, both for the plugin and your help :)

  23. Matthew Muro
    Member
    Posted 1 year ago #

    Awesome. Glad we could troubleshoot this.

    I won't have an official release to correct these bugs until after the US holidays (next week). Let me know if you find any other problems with it, though!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic