我正在使用WordPress创建一个自定义网站。我需要获取有关谁创建了帐户/用户的信息。
例如,metacreated_by
. 这样我就可以检索由用户X创建的用户和由Y创建的用户,依此类推。
我正在使用WordPress创建一个自定义网站。我需要获取有关谁创建了帐户/用户的信息。
例如,metacreated_by
. 这样我就可以检索由用户X创建的用户和由Y创建的用户,依此类推。
//Whenever a user will be created \'user_register\' hook of WordPress is executed
add_action( \'user_register\', \'meta_registration_save\', 10, 1 );
//Following function will be called on each user registration and will save the \'created_by\' information in wp_usermeta table
function meta_registration_save( $user_id ) {
//logged in user
if ( is_user_logged_in() )
{
global $current_user;
get_currentuserinfo();
$current_id=$current_user->ID;
add_user_meta( $user_id, \'Created_by\', $id );
}
else{
//in case user is registered from non logged in user
add_user_meta( $user_id, \'Created_by\', 0 );
}
}
//To get the user meta details call following function
function get_creator_of_user($userid)
{
if(( $creator_id=get_user_meta ($userid, \'Created_by\',true) )!= 0)
echo get_user_meta ($creator_id, \'nickname\',true);
else
echo \'User created by non logged in user\';
}
有很多插件可以让你通过拖放来订购页面和/或帖子。是否有与订单用户类似的内容?如果没有,是否可以为此创建一个插件(即是否有足够的过滤器、操作等)?