Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

It looks like get_user_meta() returns an array like such.

array(2) {
   [0]=>
       array(1) {
           [0]=>
       }

   [1]=>
       array(1) {
           [0]=>
       }
}

Then when update_user_meta() stores the array it sticks it inside another array like this.

Edit: As it turns out get_user_meta() is encapsulating the result in an array when it grabs it.

array(1) {
    [0]=>
        array(2) {
           [0]=>
               array(1) {
                   [0]=>
               }
           [1]=>
               array(1) {
                   [0]=>
               }
        }
}

Then later it's retrieved and saved again adding a new level each time.

There's a simple, although counter-intuitive, solution to this problem. Set the last parameter of get_user_meta() to true.

get_user_meta($id,$key,true);`

If it is false it returns an array and if it is true it returns a single value which could be an array itself.

More info is available here. http://stackoverflow.com/questions/7746887/storing-php-arrays-in-wordpress-user-meta-databasehttps://stackoverflow.com/questions/7746887/storing-php-arrays-in-wordpress-user-meta-database

It looks like get_user_meta() returns an array like such.

array(2) {
   [0]=>
       array(1) {
           [0]=>
       }

   [1]=>
       array(1) {
           [0]=>
       }
}

Then when update_user_meta() stores the array it sticks it inside another array like this.

Edit: As it turns out get_user_meta() is encapsulating the result in an array when it grabs it.

array(1) {
    [0]=>
        array(2) {
           [0]=>
               array(1) {
                   [0]=>
               }
           [1]=>
               array(1) {
                   [0]=>
               }
        }
}

Then later it's retrieved and saved again adding a new level each time.

There's a simple, although counter-intuitive, solution to this problem. Set the last parameter of get_user_meta() to true.

get_user_meta($id,$key,true);`

If it is false it returns an array and if it is true it returns a single value which could be an array itself.

More info is available here. http://stackoverflow.com/questions/7746887/storing-php-arrays-in-wordpress-user-meta-database

It looks like get_user_meta() returns an array like such.

array(2) {
   [0]=>
       array(1) {
           [0]=>
       }

   [1]=>
       array(1) {
           [0]=>
       }
}

Then when update_user_meta() stores the array it sticks it inside another array like this.

Edit: As it turns out get_user_meta() is encapsulating the result in an array when it grabs it.

array(1) {
    [0]=>
        array(2) {
           [0]=>
               array(1) {
                   [0]=>
               }
           [1]=>
               array(1) {
                   [0]=>
               }
        }
}

Then later it's retrieved and saved again adding a new level each time.

There's a simple, although counter-intuitive, solution to this problem. Set the last parameter of get_user_meta() to true.

get_user_meta($id,$key,true);`

If it is false it returns an array and if it is true it returns a single value which could be an array itself.

More info is available here. https://stackoverflow.com/questions/7746887/storing-php-arrays-in-wordpress-user-meta-database

Added info on how to fix the issue.
Source Link
epilektric
  • 2k
  • 14
  • 10

It looks like get_user_meta() returns an array like such.

array(2) {
   [0]=>
       array(1) {
           [0]=>
       }

   [1]=>
       array(1) {
           [0]=>
       }
}

Then when update_user_meta() stores the array it sticksit sticks it inside another array like this.

Edit: As it inside anotherturns out get_user_meta() is encapsulating the result in an array like thiswhen it grabs it.

array(1) {
    [0]=>
        array(2) {
           [0]=>
               array(1) {
                   [0]=>
               }
           [1]=>
               array(1) {
                   [0]=>
               }
        }
}

Then later it's retrieved and saved again adding a new level each time.

There's a simple, although counter-intuitive, solution to this problem. Set the last parameter of get_user_meta() to true.

get_user_meta($id,$key,true);`

If it is false it returns an array and if it is true it returns a single value which could be an array itself.

More info is available here. http://stackoverflow.com/questions/7746887/storing-php-arrays-in-wordpress-user-meta-database

It looks like get_user_meta() returns an array like such.

array(2) {
   [0]=>
       array(1) {
           [0]=>
       }

   [1]=>
       array(1) {
           [0]=>
       }
}

Then when update_user_meta() stores the array it sticks it inside another array like this.

array(1) {
    [0]=>
        array(2) {
           [0]=>
               array(1) {
                   [0]=>
               }
           [1]=>
               array(1) {
                   [0]=>
               }
        }
}

Then later it's retrieved and saved again adding a new level each time.

It looks like get_user_meta() returns an array like such.

array(2) {
   [0]=>
       array(1) {
           [0]=>
       }

   [1]=>
       array(1) {
           [0]=>
       }
}

Then when update_user_meta() stores the array it sticks it inside another array like this.

Edit: As it turns out get_user_meta() is encapsulating the result in an array when it grabs it.

array(1) {
    [0]=>
        array(2) {
           [0]=>
               array(1) {
                   [0]=>
               }
           [1]=>
               array(1) {
                   [0]=>
               }
        }
}

Then later it's retrieved and saved again adding a new level each time.

There's a simple, although counter-intuitive, solution to this problem. Set the last parameter of get_user_meta() to true.

get_user_meta($id,$key,true);`

If it is false it returns an array and if it is true it returns a single value which could be an array itself.

More info is available here. http://stackoverflow.com/questions/7746887/storing-php-arrays-in-wordpress-user-meta-database

Source Link
epilektric
  • 2k
  • 14
  • 10

It looks like get_user_meta() returns an array like such.

array(2) {
   [0]=>
       array(1) {
           [0]=>
       }

   [1]=>
       array(1) {
           [0]=>
       }
}

Then when update_user_meta() stores the array it sticks it inside another array like this.

array(1) {
    [0]=>
        array(2) {
           [0]=>
               array(1) {
                   [0]=>
               }
           [1]=>
               array(1) {
                   [0]=>
               }
        }
}

Then later it's retrieved and saved again adding a new level each time.