• aosipov

    (@aosipov)


    I was wondering if anyone can help me with that. I have a code for admin user extra columns:

    function new_modify_user_table( $column ) {
        $column['id'] = 'ID';
        $column['favorites'] = 'Favorites';
        return $column;
    }
    add_filter( 'manage_users_columns', 'new_modify_user_table' );
    
    function new_modify_user_table_row( $val, $column_name, $user_id ) {
        switch ($column_name) {
            case 'id' :
                return get_the_author_meta( 'ID', $user_id );
            case 'favorites' :
                return get_the_author_meta('simplefavorites', $user_id);
                var_dump($posts);
            default:
        }
        return $val;
    }
    add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );

    and my simplefavorites meta looks like this:

    array (
      0 => 
      array (
        0 => 
        array (
          'site_id' => 1,
          'posts' => 
          array (
            0 => 51380,
            1 => 60244,
            2 => 59759,
            3 => 34970,
            4 => 59849,
            5 => 49747,
            6 => 27365,
            7 => 18653,
            8 => 15613,
          ),
          'groups' => 
          array (
            0 => 
            array (
              'group_id' => 1,
              'site_id' => 1,
              'group_name' => 'Default List',
              'posts' => 
              array (
                0 => 51380,
                1 => 60244,
                2 => 59759,
                3 => 34970,
                4 => 59849,
                5 => 49747,
                6 => 27365,
                7 => 18653,
                8 => 15613,
              ),
            ),
          ),
        ),
      ),
    )

    i would like to display in the column number of posts from the array. Is this possible? What can i do? How i can drill down to array with this function?

    Thanks in advance!
    Alex

    • This topic was modified 4 years ago by aosipov.
Viewing 2 replies - 16 through 17 (of 17 total)
  • Thread Starter aosipov

    (@aosipov)

    hey @bcworkz that worked amazingly! You are genius:)
    Thank you so much.
    Next step i was thinking if i can make them clickable LOL, or maybe this is for another time!:))
    Have a great weekend!

    Moderator bcworkz

    (@bcworkz)

    Happy to help. To be clickable you just need to add anchor tags. You have the post IDs in an array before imploding, so you can get the href attribute with get_permalink($post_id)

    Get out and enjoy the weekend somewhere safe.

Viewing 2 replies - 16 through 17 (of 17 total)
  • The topic ‘wordpress user admin columns’ is closed to new replies.