Support Forum

Display Identities on Author Page

9 Answers

New Answer

MP Mr Papa
Mr Papa
Member

So I am going to assume that you already have a wp theme template file for displaying the author archive… you will need to edit that file… near the top – or at least outside the loop, add this code:

sp_forum_api_support();

that will initialize some forum data… then wherever you want in the author archive template file, you can get at the SP identity data via these php variables

$spThisUser->skype
$spThisUser->facebook
$spThisUser->twitter
$spThisUser->aim
$spThisUser->yim
$spThisUser->jabber
$spThisUser->msn
$spThisUser->icq
$spThisUser->myspace
$spThisUser->linkedin
$spThisUser->youtube
$spThisUser->googleplus

and there ya go…

CH Chozen
Chozen
Member

This is what my author page looks like http://www.ihiphopmusic.com/profile/baiyu

Now where exactly am I placing sp_forum_api_support(); ?

Does that work the same way as:

<?php 
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
?>

I know my way around WordPress design wise, but I’m a beginner in PHP.

MP Mr Papa
Mr Papa
Member

well I assume you are familiar with a wp template file then…  its a mixture of php and html, typically…  and your little example show you how to enter a php code fragment…

wp archive pages, of which the author page is one, work on the principal of the WordPress loop to display a bunch of items… typically starts with something like:

    if (have_posts()) :
    while (have_posts()) : the_post();   

though there are many, many ways to start the loop… I only want that code fragment run once to init some forum data…  I assume you will only output the identities once too… 

but not knowing your wp theme template file for the author archives, no way to tell you exactly where… somewhere near the top AND before you want to output the identities, just add

<?php
sp_forum_api_support();
?>

if its not in an php code section…  if it is, you can omit the first and last lines…

CH Chozen
Chozen
Member

So something like this?

<?php
sp_forum_api_support();
?>

<?php echo $spThisUser->facebook; ?>

MP Mr Papa
Mr Papa
Member

short answer, yes…  long answer is well, depends what you want…  that will just output their facebook account… you might want to prepend http://facebook.com/ to it…  and potentially make it a link…

CH Chozen
Chozen
Member

OK it works, now how can I warp this into a conditional?

For instance.

[If social identity exists]

<a href=”http://www.facebook.com/<?php echo $spThisUser->facebook; ?>”><img src=”www.mysite.com/facebook-icon.png”/></a>

[else]

Nothing or something else here…

[end if]

MP Mr Papa
Mr Papa
Member

if (!empty($spThisUser->facebook)) echo $spThisUser->facebook;

should do it…

CH Chozen
Chozen
Member

That works but I’m trying to load a image with a link if the social identity is available and if it’s not then display something else.

Like how I have it laid out above.

MP Mr Papa
Mr Papa
Member

sorry, laid out above??

do you mean something like this:

if (!empty($spThisUser->facebook)) echo “<a href=’http://facebook.com/$spThisUser->facebook’><img src=’xxxxx’ /></a>;

of course, you would need to fill in the xxxxx part to your image…