3c15cc88 by Chris Boden

Beta UserDetails done. String fields work

1 parent 532e7442
......@@ -4,6 +4,7 @@ use Tz, Tz\Common, Tz\WordPress\Tools;
const SETTING_NS = 'tz-user-details';
const CAPABILITY = 'edit_user_details';
const HTML_NS = 'tzud-';
call_user_func(function() {
Tz\import('Tz', 'trunk');
......@@ -25,17 +26,9 @@ function register_field($id, $display = null) { //, Common\Callback $fn = null)
Vars::$fields[$id] = Array(
'id' => $id
, 'label' => $display
// , 'callback' => $fn
);
}
/**
* @returns Array
*/
function get_registered_fields() {
// return assosative array('id' => 'val');
}
function get_user_id() {
if (isset($_GET['user_id'])) {
return $_GET['user_id'];
......@@ -58,6 +51,16 @@ class Actions {
public static function show_user_profile() {
static::edit_user_profile();
}
public static function profile_update() {
$uid = get_user_id();
foreach ($_POST as $key => $val) {
if (substr($key, 0, strlen(HTML_NS)) == HTML_NS) {
update_user_meta($uid, substr($key, strlen(HTML_NS)), $val);
}
}
}
}
class Vars {
......
......@@ -8,7 +8,7 @@ namespace Tz\WordPress\Tools\UserDetails;
<?php foreach (Vars::$fields as $id => $info): ?>
<tr>
<th><label for="<?php echo $id; ?>"><?php echo $info['label']; ?></label></th>
<td><input type="text" class="regular-text" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo esc_attr(get_user_meta(get_user_id(), $id, true )); ?>" /></td>
<td><input type="text" class="regular-text" name="<?php echo HTML_NS . $id; ?>" id="<?php echo $id; ?>" value="<?php echo esc_attr(get_user_meta(get_user_id(), $id, true )); ?>" /></td>
</tr>
<?php endforeach; ?>
</tbody></table>
\ No newline at end of file
......