break; case 'update-meta' : $mid = (int) array_pop(array_keys($_POST['meta'])); $key = $_POST['meta'][$mid]['key']; $value = $_POST['meta'][$mid]['value']; if ( !$meta = get_post_meta_by_id( $mid ) ) die('0'); // if meta doesn't exist if ( !current_user_can( 'edit_post', $meta->post_id ) ) die('-1'); if ( $u = update_meta( $mid, $key, $value ) ) { $key = stripslashes($key); $value = stripslashes($value); $x = new WP_Ajax_Response( array( 'what' => 'meta', 'id' => $mid, 'data' => wp_ajax_meta_row( $meta->post_id, $mid, $key, $value ), 'supplemental' => array('postid' => $meta->post_id) ) ); $x->send(); } die('1'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). break; case 'add-user' : if ( !current_user_can('edit_users') ) die('-1'); require_once(ABSPATH . WPINC . '/registration.php'); if ( !$user_id = add_user() ) die('0'); elseif ( is_wp_error( $user_id ) ) { foreach( $user_id->get_error_messages() as $message ) echo "<p>$message<p>";
break; case 'update-meta': $mid = (int) array_pop(array_keys($_POST['meta'])); $key = $_POST['meta'][$mid]['key']; $value = $_POST['meta'][$mid]['value']; if (!($meta = get_post_meta_by_id($mid))) { die('0'); } // if meta doesn't exist if (!current_user_can('edit_post', $meta->post_id)) { die('-1'); } if ($u = update_meta($mid, $key, $value)) { $key = stripslashes($key); $value = stripslashes($value); $x = new WP_Ajax_Response(array('what' => 'meta', 'id' => $mid, 'data' => wp_ajax_meta_row($meta->post_id, $mid, $key, $value), 'supplemental' => array('postid' => $meta->post_id))); $x->send(); } die('1'); // We know meta exists; we also know it's unchanged (or DB error, in which case there are bigger problems). break; case 'add-user': if (!current_user_can('edit_users')) { die('-1'); } require_once ABSPATH . WPINC . '/registration.php'; if (!($user_id = add_user())) { die('0'); } elseif (is_wp_error($user_id)) { foreach ($user_id->get_error_messages() as $message) { echo "<p>{$message}<p>";