无法仅检索活动成员

时间:2014-06-19 作者:angiemeeker

下面是一个页面模板,我试图在其中检索活动成员元数据(属于Restrict Content Pro)。显示用户的元数据工作正常;但我不能只显示活跃的成员,而不是每个人。我想知道下面的语法中是否有一个简单的错误可以纠正这一点。

我需要检查成员是否处于活动状态[正在使用if( rcp_is_active() )], 其中所有成员也是网站的订阅者[ $members = get_users( $args ); foreach ($members as $member)] .

<?php
/**
 * This file adds the User Directory template to the Parallax Pro Theme.
 *
 * @author StudioPress
 * @package Parallax
 * @subpackage Customizations
 */

/*
Template Name: Directory
*/

add_action( \'genesis_entry_content\', \'ogs_directory\', 5 );
function ogs_directory() {
        $args = array(
            \'blog_id\'      => 1, // unless yours is a multisite install, you shouldn\'t need to change this
            \'exclude\'      => array(), // IDs of users that need to be excluded
            \'orderby\'      => \'display_name\' // Sort by \'ID\', \'login\', \'nicename\', \'email\', \'url\', \'registered\', \'display_name\', or \'post_count\'; defaults to \'login\'
         );
         $members = get_users( $args );
         if( rcp_is_active() ) {
        foreach ($members as $member)       

            echo \'<p>\';
            echo \'<strong>Name: </strong>\' .esc_attr( $member->first_name ).  \'\' ;
            echo \'<strong> </strong>\' .esc_attr( $member->last_name ).  \'<br/> \' ;
            if ( $member->rcp_address ) {
            echo \'<strong>Address: </strong>\' .esc_attr( $member->rcp_address ).  \'<br/> \' ;
            }
            if ( $member->rcp_univ_1 ) {
            echo \'<strong>University: </strong>\' .esc_attr( $member->rcp_univ_1 ).  \'<br/> \' ;
            }
        echo \'</p>\';

         }   }

//* Run the Genesis loop
genesis();

2 个回复
SO网友:Nilambar Sharma

的花括号foreach 缺少。尝试以下操作:

/*
Template Name: Directory
*/

add_action( \'genesis_entry_content\', \'ogs_directory\', 5 );

function ogs_directory() {
        $args = array(
            \'blog_id\'      => 1, // unless yours is a multisite install, you shouldn\'t need to change this
            \'exclude\'      => array(), // IDs of users that need to be excluded
            \'orderby\'      => \'display_name\' // Sort by \'ID\', \'login\', \'nicename\', \'email\', \'url\', \'registered\', \'display_name\', or \'post_count\'; defaults to \'login\'
         );
         $members = get_users( $args );
         if( rcp_is_active() ) {
        foreach ($members as $member)   {


              echo \'<p>\';
              echo \'<strong>Name: </strong>\' .esc_attr( $member->first_name ).  \'\' ;
              echo \'<strong> </strong>\' .esc_attr( $member->last_name ).  \'<br/> \' ;
              if ( $member->rcp_address ) {
              echo \'<strong>Address: </strong>\' .esc_attr( $member->rcp_address ).  \'<br/> \' ;
              }
              if ( $member->rcp_univ_1 ) {
              echo \'<strong>University: </strong>\' .esc_attr( $member->rcp_univ_1 ).  \'<br/> \' ;
              }
              echo \'</p>\';
          }  // end foreach  

         } // end if   

       } // end function

//* Run the Genesis loop
genesis();

SO网友:angiemeeker

if( rcp_is_active() 不适合我想做的事。我需要rcp_get_members(). 改变这一点,并在上面缺少的括号中添加内容,使我能够产生我想要的结果。非常感谢。

add_action( \'genesis_entry_content\', \'ogs_directory\', 5 );
function ogs_directory() {
        $args = array(
            \'blog_id\'      => 1, // unless yours is a multisite install, you shouldn\'t need to change this
            \'exclude\'      => array(), // IDs of users that need to be excluded
            \'orderby\'      => \'display_name\' // Sort by \'ID\', \'login\', \'nicename\', \'email\', \'url\', \'registered\', \'display_name\', or \'post_count\'; defaults to \'login\'
         );
         $members = rcp_get_members();
        foreach ($members as $member) {     

            echo \'<p>\';
            echo \'<strong>Name: </strong>\' .esc_attr( $member->first_name ).  \'\' ;
            echo \'<strong> </strong>\' .esc_attr( $member->last_name ).  \'<br/> \' ;
            if ( $member->rcp_address ) {
            echo \'<strong>Address: </strong>\' .esc_attr( $member->rcp_address ).  \'<br/> \' ;
            }
            if ( $member->rcp_univ_1 ) {
            echo \'<strong>University: </strong>\' .esc_attr( $member->rcp_univ_1 ).  \'<br/> \' ;
            }
        echo \'</p>\';

         }   }

//* Run the Genesis loop
genesis();

结束

相关推荐

按上次登录日期排序Get_Users()。有可能吗?

我想创建一个页面,显示按上次登录日期排序的所有博客用户。我尝试了get\\u users()函数,我可以成功地获取用户列表,但不是按照我想要的顺序:$query = get_users(\'&offset=\'.$offset.\'&orderby=login&order=DESC&number=\'.$number); 我认为orderby=登录不是我想要的。。。有没有其他方法可以做到这一点?