Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Display Identities on Author Page
Avatar
Chozen
Rookie
Free Members
sp_UserOfflineSmall Offline
Jul 2, 2012 - 6:21 pm

How do I display social identities from Simple Press on the WordPress author page?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jul 2, 2012 - 7:17 pm

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

Avatar
Chozen
Rookie
Free Members
sp_UserOfflineSmall Offline
Jul 2, 2012 - 8:31 pm

This is what my author page looks like http://www.ihiphopmusic.com/pr.....file/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.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jul 2, 2012 - 8:53 pm

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

Avatar
Chozen
Rookie
Free Members
sp_UserOfflineSmall Offline
Jul 2, 2012 - 9:02 pm

So something like this?

<?php
sp_forum_api_support();
?>

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

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jul 2, 2012 - 9:09 pm

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

Avatar
Chozen
Rookie
Free Members
sp_UserOfflineSmall Offline
Jul 2, 2012 - 9:12 pm

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]

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jul 2, 2012 - 9:47 pm

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

should do it...

Avatar
Chozen
Rookie
Free Members
sp_UserOfflineSmall Offline
Jul 2, 2012 - 10:00 pm

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.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jul 3, 2012 - 1:55 am

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

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626