谢谢你的关注,我和update_user_meta这是我写的小函数
global $blog_id;
$current_blog_details = get_blog_details( array( \'blog_id\' => $blog_id ) );
if (is_user_logged_in()) {
$user = wp_get_current_user();
$last_visited_blogs = get_user_meta($user->ID, \'last_visited_blogs\',true);
if($last_visited_blogs) {
if (end($last_visited_blogs) != $current_blog_details->blogname) {
if (count($last_visited_blogs) < 5) {
array_push($last_visited_blogs, $current_blog_details->blogname);
} else {
array_shift($last_visited_blogs);
array_push($last_visited_blogs, $current_blog_details->blogname);
}
update_user_meta($user->ID, \'last_visited_blogs\', $last_visited_blogs);
}
} else {
$last_visited_blogs = array($current_blog_details->blogname);
update_user_meta($user->ID, \'last_visited_blogs\', $last_visited_blogs);
}
$last_visited_blogs_reversed = array_reverse($last_visited_blogs);
foreach($last_visited_blogs_reversed as $key => $value) {
$wp_admin_bar->add_menu( array(
\'id\' => $value,
\'title\' => $value,
\'href\' => admin_url( \'didiyle.php\' ),
) );
}
}
我在我的管理栏中使用它,如果你需要,你可以在任何地方使用它,尽管需要一些修改