Wordpress - ACF - 带有x 2字段过滤器的管理员/用户列表

时间:2018-05-29 03:59:45

标签: php wordpress

我跟随Wordpress - filter admin user list with custom field (ACF)跟随在function.php中添加自定义ACF字段

它运行正常,当我尝试将用户ID字段添加到函数中时,一切都停止工作。

有没有人有线索?感谢

更新:Col1(显示ACF字段)和Col2(显示用户ID)工作正常,但我无法弄清楚同时显示Col1 + Col2,当我放入两个脚本时不断收到错误。

// --- Col 1 --

add_filter( 'manage_users_columns', 'column_register_wpse_101322' );
add_filter( 'manage_users_custom_column', 'column_display_wpse_101322', 10, 3 );
function column_register_wpse_101322( $columns )
{

    $columns['accountmanager_col'] = 'Opiekun';
    return $columns;
}



 function column_display_wpse_101322( $post_id, $column_name, $opiekunklienta )
{


$opiekunklienta_code = get_user_meta( $opiekunklienta,'opiekun_klienta',true); 

    if ( 'accountmanager_col' != $column_name )
    return $empty;    
    return "<strong>$opiekunklienta_code</strong>";
}

// ---- Col 2 ----
add_filter( 'manage_users_columns', 'column_register_wpse_101322' );
add_filter( 'manage_users_custom_column', 'column_display_wpse_101322', 10, 3 );

function column_register_wpse_101322( $columns ) 
{
    $columns['uid'] = 'ID';
    return $columns;
}

function column_display_wpse_101322( $empty, $column_name, $user_id ) 
{
    if ( 'uid' != $column_name )
        return $empty;

    return "<strong>$user_id</strong>";
}    

0 个答案:

没有答案