admin管理员组文章数量:1432213
I'm trying to add a "last modified" date to user profiles on WordPress. I'm using the Ultimate Member plugin, so I would prefer to to find a way to save this date to a meta-key that I can pull when I do a search as well.
So far, I this is what I have using a shortcode [wppb-last-updated]
, but it displays the currently logged in user's last modified date. As an admin, I need to see when others have last modified their own information. Any suggestions?
add_filter('wppb_edit_profile_all_changes_saved', 'wppb_last_updated_save');
add_filter('wppb_edit_profile_all_changes_saved_except_existing_email', 'wppb_last_updated_save');
add_filter('wppb_edit_profile_all_changes_saved_except_invalid_email', 'wppb_last_updated_save');
add_filter('wppb_edit_profile_all_changes_saved_except_mismatch_password', 'wppb_last_updated_save');
add_filter('wppb_edit_profile_all_changes_saved_except_uncompleted_password', 'wppb_last_updated_save');
function wppb_last_updated_save($content){
$user = wp_get_current_user();
update_user_meta( $user->ID, 'wppb_last_updated', date("d / M / Y") );
return $content;
}
add_shortcode( 'wppb-last-updated', 'wppb_last_updated_print');
function wppb_last_updated_print(){
$user = wp_get_current_user();
$last_updated = get_user_meta($user->ID, 'wppb_last_updated', true );
if ( $last_updated == '' ){
$udata = get_userdata( $user->ID );
$registered = $udata->user_registered;
return date( "m/d/Y", strtotime( $registered ) );
}
return $last_updated;
}
EDIT: Is there an alternative method of pulling up the modified date of a user profile via shortcode and parameter anywhere on the site? Something like this?
/**
* Shortcode for Displaying Last Modified Date of User Profile
* Usage: [wppb-last-updated user_id="1"]
*/
add_filter('wppb_edit_profile_all_changes_saved', 'wppb_last_updated_save');
add_filter('wppb_edit_profile_all_changes_saved_except_existing_email', 'wppb_last_updated_save');
add_filter('wppb_edit_profile_all_changes_saved_except_invalid_email', 'wppb_last_updated_save');
add_filter('wppb_edit_profile_all_changes_saved_except_mismatch_password', 'wppb_last_updated_save');
add_filter('wppb_edit_profile_all_changes_saved_except_uncompleted_password', 'wppb_last_updated_save');
function wppb_last_updated_save($content){
$user = $user_id;
update_user_meta( $user->ID, 'wppb_last_updated', date("d / M / Y") );
return $content;
}
add_shortcode( 'wppb-last-updated', 'wppb_last_updated_print');
function wppb_last_updated_print($atts){
$user_id = shortcode_atts( array('user_id' => ''), $atts );
$last_updated = get_user_meta($user->ID, 'wppb_last_updated', true );
if ( $last_updated == '' ){
$udata = get_userdata( $user->ID );
$registered = $udata->user_registered;
return date( "m/d/Y", strtotime( $registered ) );
}
return $last_updated;
}
本文标签: phpHow Can I Display the Last Modified Date for User Profiles on WordPress
版权声明:本文标题:php - How Can I Display the Last Modified Date for User Profiles on WordPress? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745505660a2661231.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论