-
-
Save fritids/79f0854020edd3c9b5fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace ShowMemberSince; | |
add_action( 'plugins_loaded', 'ShowMemberSince\init' ); | |
/** | |
* Adding needed action hooks | |
*/ | |
function init(){ | |
foreach( array( 'show_user_profile', 'edit_user_profile' ) as $hook ) | |
add_action( $hook, 'ShowMemberSince\add_custom_user_profile_fields', 10, 1 ); | |
} | |
/** | |
* Output table | |
* @param object $user User object | |
*/ | |
function add_custom_user_profile_fields( $user ){ | |
$table = | |
'<h3>%1$s</h3> | |
<table class="form-table"> | |
<tr> | |
<th> | |
%1$s | |
</th> | |
<td> | |
<p>Member since: %2$s</p> | |
</td> | |
</tr> | |
</table>'; | |
$udata = get_userdata( $user-ID ); | |
$registered = $udata->user_registered; | |
printf( | |
$table, | |
'Registered', | |
date( "M Y", strtotime( $registered ) ) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment