Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using the Mingle plugin to add some networking functionality for a website I am creating for a client. I am having Mingle handle displaying user profiles and friends, but WordPress to actually register users and put in fields.

Mingle has the ability to add custom fields (ex: Twitter, Facebook, etc). However, there is no way to display these custom fields individually. So, I have added my own custom fields to WordPress using the functions.php file:

function add_new_contactmethods( $methods ) {
    $methods['twitter'] = 'Twitter';
    return $methods;
}
add_filter( 'user_contactmethods','add_new_contactmethods' );

I am displaying them within one of the Mingle templates (mingle/classes/views/mngl-profiles/profile.php):

<?php if ( get_the_author_meta( 'twitter' ) ) { ?>
    <a href="http://twitter.com/<?php the_author_meta( 'twitter' ); ?>" title="Follow @<?php the_author_meta( 'twitter' ); ?> on Twitter">
        <div class="tile bg-color-twitter icon">
            <div class="tile-content">
                <img src="<?php echo THEME_DIR; ?>/images/icons/twitter.png" alt="Twitter" class="socialIcon" />
            </div>
            <div class="brand">
                <span class="name">@<?php the_author_meta( 'twitter' ); ?></span>
            </div>
        </div><!-- .tile -->
    </a>
<?php } ?>

Now whenever I go to a profile page that is generated by Mingle, (http://example.com/admin or http://example.com/dylan), whoever is currently logged in at the moment will have their custom fields shown, not to the user whose profile is being shown.

Does that make sense? I can provide more code or elaborate if need be. I would really, really appreciate any and all help I can receive on this, the project is really time-sensitive.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You're outside the loop, so you should supply a user ID:

get_the_author_meta( 'twitter', $user->id )

share|improve this answer
    
Thank you for your help! What value should the variable $user hold? –  Keenan Payne Jan 15 '13 at 23:30
    
I think it's available on the page, give it a try! –  diggy Jan 15 '13 at 23:36
    
Right now when I use get_the_author_meta( 'twitter', 1 ) it knows to display the custom field or not, and it retrieves the correct information. However, when I use $user->id it does not work, as if it is not retrieving the ID. –  Keenan Payne Jan 15 '13 at 23:37
    
what about $mngl_user->id –  diggy Jan 15 '13 at 23:38
    
That did not work. However, I was including this part of the code (because the client wants 15 social networking custom fields) so I included it in a file called <em>social-networks.php</em> then used get_template_part('social', 'networks'); to include it in the Mingle template. Well, when I got rid of get_template_part, added $user->id and put all of the code just in the file, it worked. So get_template_part was the problem it seems. Thank you for your answer and help though, I got it figured out! :) –  Keenan Payne Jan 15 '13 at 23:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.