[Plugin: Restrict Categories] Error when using plugin…
-
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
-
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.
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
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)?
Thank you for your answer,
I just udpdated but:
Downloading update from http://downloads.wp.xz.cn/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 277I 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.
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.
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 279Like 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.
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
For some reason, get_user_meta is returning an empty string. What version of WordPress are you running?
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.
How comfortable are you with MySQL?
If you can use phpMyAdmin or something similar to access your database, open the
wp_usermetatable and find thewp_capabilitiesentries under themeta_keycolumn. You should have one for each user role. Paste in one of themeta_valuehere. It’ll look something like this:a:1:{s:13:"administrator";s:1:"1";}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 admina:1:{s:11:"contributor";s:1:"1";}
for the 6 contributors i createdbut 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.phpso 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.
Is the meta_key called
wp_capabilities?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.
nope, is
test_capabilitiesas a side note I tried the bad way :p
changing any istance of
wp_capabilitiesin the plugin withtest_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 280Line280:
foreach ( $settings[$key . '_cats'] as $category ) {maybe mine is not the best solution…
edit: sorry I wrote while you where posting
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 🙂
The topic ‘[Plugin: Restrict Categories] Error when using plugin…’ is closed to new replies.