WordPress.org

Support

Support » Plugins and Hacks » Youtube Profile Field » [Resolved] [Plugin: Youtube Profile Field] All users

[Resolved] [Plugin: Youtube Profile Field] All users

Viewing 11 replies - 1 through 11 (of 11 total)
  • Hello,

    You can make a PHP loop that goes through every user and display their videos.

    Something like this (untested):

    $users = get_users();
    
    if ( $users && function_exists( 'ypf_show_video' ) ) :
      foreach ( $users as $user ) {
              echo 'Videos from ' . $user->user_nicename;
              echo ypf_show_video( array( 'user_id' => $user->ID ) );
      }
    endif;
    

    2. What do you mean by “it would be useful the youtube username to display in users.php like name.” ??

    Hello Jesper, thanks for reply. I am not sure how to use the code you suggested…

    I mean that would be nice to see user’s YouTube username when I visit “wp-admin/users.php”. Like username, name, email, role…

    Here it is as a shortcode:

    function stergos_ypf_all_users() {
     $users = get_users();
    
     if ( $users && function_exists( 'ypf_show_video' ) ) :
       foreach ( $users as $user ) {
              $text = 'Videos from ' . $user->user_nicename;
              $text .= ypf_show_video( array( 'user_id' => $user->ID ) );
       }
       return $text;
     endif;
     return;
    }
    
    add_shortcode( 'ypf-all', 'stergos_ypf_all_users' );
    

    When use the shortcode: [ypf-all]… Again untested but should work

    2. Something like this:

    <?php
    function stergos_ypf_user_table( $column ) {
        $column['youtube'] = 'Youtube username';
    
        return $column;
    }
    
    add_filter( 'manage_users_columns', 'stergos_ypf_user_table' );
    
    function stergos_ypf_modify_user_table_row( $val, $column_name, $user_id ) {
        $user = get_userdata( $user_id );
    
        switch ($column_name) {
            case 'youtube' :
                return $user->youtube;
                break;
    
            default:
        }
    
        return $return;
    }
    
    add_filter( 'manage_users_custom_column', 'stergos_ypf_modify_user_table_row', 10, 3 );
    
    ?>
    
    
    
    		
    	

    Strange… but in the first case is return videos only from one specific user…

    My mistake!

    Try this:

    function stergos_ypf_all_users() {
     $users = get_users();
    
     if ( $users && function_exists( 'ypf_show_video' ) ) :
       foreach ( $users as $user ) {
              $text .= 'Videos from ' . $user->user_nicename;
              $text .= ypf_show_video( array( 'user_id' => $user->ID ) );
       }
       return $text;
     endif;
     return;
    }
    
    add_shortcode( 'ypf-all', 'stergos_ypf_all_users' );
    

    Thank you very much Jesper is working like a charm!

    One last thing, I know maybe is too much and I am apologize if I waste your time… is there any way to brake the page per 10 videos? I usually doing this by adding the shortcode <!–nextpage–> but this is not going to work in this case…

    Thank you!!!

    Not that I can think of. Maybe you can with javascript/jQuery.

    Thanks anyway Jesper 🙂

    One more thing please, I have many fanatic users from Youtube so is very important to manage them, your second code is worked great into my functions (users.php); is there any way to link ‘Youtube username’ “sort by” like username, name and email? I notice that username is link to wp-admin/users.php?orderby=login&order=desc. Thanks!

    Okay mate thanks for once again!

    I offer reward if you or anyone can help on these 2 issues. (sort by in user list and paginate)

    Regards…

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘[Resolved] [Plugin: Youtube Profile Field] All users’ is closed to new replies.
Skip to toolbar