Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Tenzing
/
Tz Tools
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
3c15cc88
authored
2010-10-28 14:40:43 +0000
by
Chris Boden
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Beta UserDetails done. String fields work
1 parent
532e7442
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
com/UserDetails/UserDetails.php
com/UserDetails/view-user_profile.php
com/UserDetails/UserDetails.php
View file @
3c15cc8
...
...
@@ -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
{
...
...
com/UserDetails/view-user_profile.php
View file @
3c15cc8
...
...
@@ -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
...
...
Please
register
or
sign in
to post a comment