Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Undefined index: std and id in my theme WordPress

  • SOLVED

I have an issue when I activate WP_DEBUG.

The issue apparently is on this line...

"$defaults[$value['id']] = $value['std'];"

Here's the code...


if ($value['type'] == 'multicheck'){
if (is_array($value['std'])){
foreach($value['std'] as $i=>$key){
$defaults[$value['id']][$key] = true;
}
} else {
$defaults[$value['id']][$value['std']] = true;
}
} else {
$defaults[$value['id']] = $value['std'];
}


Any ideas?

Answers (2)

2011-04-25

Michael Fields answers:

Please try the following instead:

if ( isset( $value['type'] ) && isset( $value['id'] ) && isset( $value['std'] ) && 'multicheck' == $value['type'] ) {
if ( is_array( $value['std'] ) ){
foreach( $value['std'] as $i => $key ){
$defaults[$value['id']][$key] = true;
}
}
else {
$defaults[$value['id']][$value['std']] = true;
}
}
else if ( isset( $value['id'] ) && isset( $value['std'] ) ) {
$defaults[$value['id']] = $value['std'];
}


Armand Morin comments:

That did it... worked perfectly.

I have a few other issues as well along the same lines.

Thanks Michael.

2011-04-25

Utkarsh Kukreti answers:

You're missing the 'id' and 'std' keys of a multicheck field in the original options array you're passing to this. Could you paste the rest of the script?