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
532e7442
authored
2010-10-27 22:11:14 +0000
by
Chris Boden
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
UserDetails working
1 parent
6ad8bd9e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
0 deletions
com/UserDetails/UserDetails.php
com/UserDetails/view-user_profile.php
com/UserDetails/UserDetails.php
0 → 100644
View file @
532e744
<?php
namespace
Tz\WordPress\Tools\UserDetails
;
use
Tz
,
Tz\Common
,
Tz\WordPress\Tools
;
const
SETTING_NS
=
'tz-user-details'
;
const
CAPABILITY
=
'edit_user_details'
;
call_user_func
(
function
()
{
Tz\import
(
'Tz'
,
'trunk'
);
$role
=
get_role
(
'administrator'
);
$role
->
add_cap
(
CAPABILITY
);
Tools\add_actions
(
__NAMESPACE__
.
'\Actions'
);
// This for later if done via front end instead of backend
//Vars::$meta_fields = new Tools\WP_Option(SETTING_NS);
});
function
register_field
(
$id
,
$display
=
null
)
{
//, Common\Callback $fn = null) {
if
(
is_null
(
$display
))
{
$display
=
ucwords
(
str_replace
(
Array
(
'-'
,
'_'
),
' '
,
$id
));
}
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'
];
}
if
(
isset
(
$_POST
[
'user_id'
]))
{
return
$_POST
[
'user_id'
];
}
global
$current_user
;
get_currentuserinfo
();
return
$current_user
->
ID
;
}
class
Actions
{
public
static
function
edit_user_profile
()
{
require
(
__DIR__
.
DIRECTORY_SEPARATOR
.
'view-user_profile.php'
);
}
public
static
function
show_user_profile
()
{
static
::
edit_user_profile
();
}
}
class
Vars
{
/**
* @private
* @deprecated
*/
public
static
$meta_fields
;
public
static
$fields
=
Array
();
}
?>
\ No newline at end of file
com/UserDetails/view-user_profile.php
0 → 100644
View file @
532e744
<?php
namespace
Tz\WordPress\Tools\UserDetails
;
?>
<h3>
Additional Info
</h3>
<table
class=
"form-table"
><tbody>
<?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>
</tr>
<?php
endforeach
;
?>
</tbody></table>
\ No newline at end of file
Please
register
or
sign in
to post a comment