Wordpress-获取以下用户的用户列表

时间:2018-07-16 22:24:43

标签: php wordpress list author

我正在使用插件“ user following system”,我需要获得的只是一份我关注的用户列表。我用下面的代码片段尝试了它,但是它总是返回一个数组! 我在做什么错了?

function pwuf_get_following( $user_id = 0 ) {

	if ( empty( $user_id ) ) {
		$user_id = get_current_user_id();
	}

	$following = get_user_meta( $user_id, '_pwuf_following', true );

	if ( empty( $following ) ) {

	return;

	}
	return (array) apply_filters( 'pwuf_get_following', $following, $user_id );

ob_start(); ?> 
<ul>
    <?php
	$following = get_user_meta( $user_id, '_pwuf_following', true );
 foreach( $following as $user ) { ?>
        <li><?php echo $user->first_name; ?> <?php echo $user->last_name; ?></li>
   <?php } ?>
</ul>
 <?php

  return ob_get_clean();
}
add_shortcode( 'following', 'pwuf_get_following' );

0 个答案:

没有答案