Skip to content

Commit

Permalink
Handle user/comment multi simple meta issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgol committed Sep 23, 2014
1 parent 70c77d5 commit ee1f657
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions classes/PodsAPI.php
Expand Up @@ -400,7 +400,7 @@ public function save_user_meta ( $id, $user_meta = null, $strict = false, $field
else {
$simple = false;

if ( isset( $fields[ $meta_key ] ) && is_array( $meta_value ) ) {
if ( isset( $fields[ $meta_key ] ) ) {
$field_data = $fields[ $meta_key ];

$simple = ( 'pick' == $field_data[ 'type' ] && in_array( pods_var( 'pick_object', $field_data ), $simple_tableless_objects ) );
Expand All @@ -409,6 +409,10 @@ public function save_user_meta ( $id, $user_meta = null, $strict = false, $field
if ( $simple ) {
delete_user_meta( $id, $meta_key );

if ( ! is_array( $meta_value ) ) {
$meta_value = array( $meta_value );
}

foreach ( $meta_value as $value ) {
add_user_meta( $id, $meta_key, $value );
}
Expand Down Expand Up @@ -526,7 +530,7 @@ public function save_comment_meta ( $id, $comment_meta = null, $strict = false,
else {
$simple = false;

if ( isset( $fields[ $meta_key ] ) && is_array( $meta_value ) ) {
if ( isset( $fields[ $meta_key ] ) ) {
$field_data = $fields[ $meta_key ];

$simple = ( 'pick' == $field_data[ 'type' ] && in_array( pods_var( 'pick_object', $field_data ), $simple_tableless_objects ) );
Expand All @@ -535,6 +539,10 @@ public function save_comment_meta ( $id, $comment_meta = null, $strict = false,
if ( $simple ) {
delete_comment_meta( $id, $meta_key );

if ( ! is_array( $meta_value ) ) {
$meta_value = array( $meta_value );
}

foreach ( $meta_value as $value ) {
add_comment_meta( $id, $meta_key, $value );
}
Expand Down

0 comments on commit ee1f657

Please sign in to comment.