Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php elementor模块输出的作者ID错误_Php_Loops_Wordpress Theming_Elementor - Fatal编程技术网

Php elementor模块输出的作者ID错误

Php elementor模块输出的作者ID错误,php,loops,wordpress-theming,elementor,Php,Loops,Wordpress Theming,Elementor,我为elementor创建了一个模块。我需要显示作者姓名,从elementor管理控件中选择。 我有4个管理员。它们正确显示在控制面板上: 管理员(ID=0。) Jhon Doe(ID=1) 珍妮·多伊(ID=3) 玛丽·多伊(ID=5) Elementor管理面板的代码: <php //Get all author $blogusers = get_users('blog_id=1&orderby=nicename&role=Administrator'); f

我为elementor创建了一个模块。我需要显示作者姓名,从elementor管理控件中选择。 我有4个管理员。它们正确显示在控制面板上:

  • 管理员(ID=0。)
  • Jhon Doe(ID=1)
  • 珍妮·多伊(ID=3)
  • 玛丽·多伊(ID=5)
  • Elementor管理面板的代码:

     <php 
     //Get all author
     $blogusers = get_users('blog_id=1&orderby=nicename&role=Administrator');
     foreach ($blogusers as $user) {
    
    $author_list[] = $user->user_nicename; }
    
            $this->add_control(
                'my_authorname',
                    [
                        'label'       => __( 'From AUTHOR', 'my_authorname-for-elementor' ),
                        'type' => Controls_Manager::SELECT, 
                        'options' => $author_list,
                        'default' => 'admin'
                    ]
            ); ?>   
        
    
    user\u nicename;}
    $this->add_控件(
    “我的作者姓名”,
    [
    'label'=>\('From AUTHOR','my\u authorname-for-elementor'),
    'type'=>控件管理器::选择,
    “选项”=>$author\u列表,
    '默认'=>'管理员'
    ]
    ); ?>   
    
    当我从Elementor control admin中选择Jeane Doe时,frontpage上的输出显示错误的作者ID(1,Jeane Doe ID为3)。不是我需要的作者姓名

    输出的代码:

     <?php echo $settings['my_authorname'];  ?>
    
    
    
    非常感谢您的帮助。

    改变

    $author\u list[]=$user->user\u name

    $author\u list[$user->ID]=$user->user\u name


    请参阅:此处的“参数”部分:

    谢谢,由于忘记了转换用户ID,我失去了理智。这是一项完美的工作。非常感谢。