WordPress.org

Ready to get started?Download WordPress

Forums

Youtube Profile Field
[resolved] All users (12 posts)

  1. Stergos
    Member
    Posted 2 years ago #

    Hello and thank you for this useful plugin!

    I'm wonder if there is anyway to use some shortcode to show all users videos in one page.

    Thanks in advance!

    Also a recommendation, it would be useful the youtube username to display in users.php like name.

    http://wordpress.org/extend/plugins/youtube-profile-field/

  2. Jesper Johansen (jayjdk)
    Member
    Plugin Author

    Posted 2 years ago #

    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." ??

  3. Stergos
    Member
    Posted 2 years ago #

    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...

  4. Jesper Johansen (jayjdk)
    Member
    Plugin Author

    Posted 2 years ago #

    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 );
    
    ?>
    
  5. Stergos
    Member
    Posted 2 years ago #

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

  6. Jesper Johansen (jayjdk)
    Member
    Plugin Author

    Posted 2 years ago #

    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' );
    
  7. Stergos
    Member
    Posted 2 years ago #

    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!!!

  8. Jesper Johansen (jayjdk)
    Member
    Plugin Author

    Posted 2 years ago #

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

  9. Stergos
    Member
    Posted 2 years ago #

    Thanks anyway Jesper :)

  10. Stergos
    Member
    Posted 2 years ago #

    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!

  11. Jesper Johansen (jayjdk)
    Member
    Plugin Author

    Posted 2 years ago #

  12. Stergos
    Member
    Posted 2 years ago #

    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...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic