The MU forums have moved to WordPress.org

A profile page for each author (11 posts)

  1. BrunoAmaral
    Member
    Posted 15 years ago #

    This used to work like a charm for a standalone wordpress, but I haven't been able to find the MU equivalent.

    Any ideias?

    function get_user_info () {

    if(isset($_GET['author_name'])) :
    $curauth = get_userdatabylogin($author_name); // NOTE: 2.0 bug requires get_userdatabylogin(get_the_author_login());
    else :
    $curauth = get_userdata(intval($author));
    endif;

    }

    /**
    * function user_profile() - outputs default user information + gravatar
    *
    */

    function user_profile() {

    ?>
    <h1>About: <?php echo $curauth->display_name; ?></h1><?php

    echo get_avatar($curauth->user_email);
    ?>
    <dl>
    <dt>E-mail</dt>
    <dd><?php echo $curauth->user_email; ?></dd>

    <dt>AIM / MSN</dt>
    <dd><?php echo $curauth->aim;?></dd>

    <dt>Gtalk</dt>
    <dd><?php echo $curauth->jabber;?></dd>

    <dt>Website</dt>
    <dd>user_url; ?>"><?php echo $curauth->user_url; ?></dd>

    <dt>More profile information</dt>
    <dd><?php echo $curauth->user_description; ?></dd>
    </dl>

  2. andrea_r
    Moderator
    Posted 15 years ago #

    What happens when you try it on a MU setup?

  3. BrunoAmaral
    Member
    Posted 15 years ago #

    All I get is a blank output. The only thing that show's us are the <dt> tags.

    I think the problem is the initial get_user_info function.

  4. andrea_r
    Moderator
    Posted 15 years ago #

    You put this in a page template, right?

  5. BrunoAmaral
    Member
    Posted 15 years ago #

    yes, an author.php template.

  6. dsader
    Member
    Posted 15 years ago #

    In order for the GET to , well, get, you have to click on the_author_posts_link generated within The Loop of your index.php(AKA the byline).

    Then your author.php kicks in... after creating a new page and setting the dropdown page template to "Author"

    What you have pasted above is very different from the example at the codex.wordpress.org

  7. BrunoAmaral
    Member
    Posted 15 years ago #

    Yes, I have a whole list of users generated with wp_list_authors()

    the template will then call those two functions and would, in theory, display the author information.

  8. MrBrian
    Member
    Posted 15 years ago #

    The code you posted doesnt make sense to me. Theres two functions, yet the variables they use are not initliazed and it isn't shown how they even interact. If this is your entire code, i'm not surprised it doesnt work. To start, you're setting $curauth inside one function, and then trying to get it's data in another function. That doesn't work on PHP, google "php variable scope". User_profile should have something like this on the first line
    $curauth = get_user_info();

    and then you need to fix the get_user_info function to actually return data, and where is $author_name and $author even being initialized?

  9. andrea_r
    Moderator
    Posted 15 years ago #

    Yeah, something's up because I know this works in MU.

  10. blogono
    Member
    Posted 15 years ago #

    its a nice idea, would be great with ..

    msn, aim, guestbook, rating, and stuff

    i have done this with bbpress, but did not add these exta stuff

    eg.
    http://blogono.com/profile.php?id=121

  11. BrunoAmaral
    Member
    Posted 15 years ago #

    Guys, thank you for all your patience.

    I got it to work using the following code instead of placing the functions in the template:

    <?php
    get_header(); 
    
    if(isset($_GET['author_name'])) :
    $curauth = get_userdatabylogin($author_name); // NOTE: 2.0 bug requires get_userdatabylogin(get_the_author_login());
    else :
    $curauth = get_userdata(intval($author));
    endif;
    
    ?>
    
    <!-- Container -->
    <div class="CON">
    
    <!-- Start SCS -->
    <div class="SCS">
    <?php include (TEMPLATEPATH . "/menu.php"); ?>
    
    <h1>About: <?php echo $curauth->display_name; ?></h1><?php
    
    echo get_avatar($curauth->user_email);
    ?>
    <dl>
    <dt>E-mail</dt>
    <dd><?php echo $curauth->user_email; ?></dd>
    
    <dt>AIM / MSN</dt>
    <dd><?php echo $curauth->aim;?></dd>
    
    <dt>Gtalk</dt>
    <dd><?php echo $curauth->jabber;?></dd>
    
    <dt>Website</dt>
    <dd><a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></dd>
    
    <dt>More profile information</dt>
    <dd><?php echo $curauth->user_description; ?></dd>
    </dl>
    
    </div>
    <!-- End SC -->
    <?php get_sidebar(); ?>
    
    <!-- Container -->
    </div>
    
    <?php get_footer(); ?>

    but I still would like to fit all this code into one or two functions. That way it would be a lot easier to hack new themes or templates.

    I will leave that for a future attempt. Thank you all again :)

About this Topic

  • Started 15 years ago by BrunoAmaral
  • Latest reply from BrunoAmaral