Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
requests-topic
Simple:Press Widget Idea/Add-on
Avatar
Maximillion
Member
sp_UserOfflineSmall Offline
Aug 6, 2012 - 10:56 pm

Yellow Swordfish said
I think - or at least I assume - that Steve posted the wrong functions. I believe he meant these two from the template tags plugin:

sp_ShowForumRankTag() and sp_ShowSpecialRanksTag()

You can get the calling details for both from this codex age: http://codex.simple-press.com/.....gs-plugin/

Hey Andy,

Tried the method you pointed out and neither the shortcode or the php code seemed to work. I checked out the codex and then used the shortcode which should have displayed my forum rank and special rank (according to user ID) and neither worked. The shortcode just got printed out like so:

[sp_ShowForumRankTag

'3'

]

[sp_ShowSpecialRanksTag

'3'

]
 

I did make sure the template tags were activated. Perhaps I missed something else?

-Max

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Aug 6, 2012 - 11:34 pm

not sure what all those things are you posted... 

where are you putting them?  widget?  page/post?  wp theme template file? 

the template tag would be:

<?php sp_ShowForumRankTag(3); ?>

you could of course use a variable for the user id instead of the number, but I just used what you showed...

for the shortcode, it would be:

[sp_forum_rank userid="3"]

Now shortcodes are made for posts/pages...so if you use in wp theme template file or widget, you need to do:

<?php echo do_shortcode('[sp_forum_rank userid="3"]'); ?>

If you are using in text widget, you need to make sure it supports php, like the exec_php plugin...

Avatar
Maximillion
Member
sp_UserOfflineSmall Offline
Aug 6, 2012 - 11:43 pm

Mr Papa said
you could of course use a variable for the user id instead of the number, but I just used what you showed...

Hey Steve,

Got it to work - not quite sure what all that crazy formatting was in my post either - oh well.

What is the variable you are mentioning for the currently logged in user ID? I would like to be able to set it up for anyone logged in.

Thank you sir!

-Max

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Aug 6, 2012 - 11:56 pm

for current user, I would use

global $current_user;

then the variable is

$current_user->ID

if its empty or 0, then its a guest or user not signed in...

Avatar
Maximillion
Member
sp_UserOfflineSmall Offline
Aug 7, 2012 - 2:35 am

Mr Papa said
for current user, I would use

global $current_user;

then the variable is

$current_user->ID

if its empty or 0, then its a guest or user not signed in...

So this?

<?php sp_ShowForumRankTag($current_user);?>

That particular combo doesn't seem to work for me but I am going to assume that's my lack of knowledge.

-Max

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Aug 7, 2012 - 2:45 am

You need the code as Steve wrote it. So something like this:

<?php 
global $current_user;
if ( $current_user->ID ) {
    sp_ShowForumRankTag($current_user);
}
?>

should work.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Maximillion
Member
sp_UserOfflineSmall Offline
Aug 7, 2012 - 3:01 am

Hmmm put it in the exec_php widget and it kinda blew up. Got this:

Warning: array_key_exists() [function.array-key-exists]: The first argument should be either a string or an integer in /problem-with-post-edit-buttonome/problem-with-post-edit-buttonomesite/public_html/wp-content/plugins/simple-press/sp-api/sp-api-class-user.php on line 320

Catchable fatal error: Object of class WP_User could not be converted to string in /problem-with-post-edit-buttonome/homesite/public_html/wp-content/plugins/simple-press/sp-api/sp-api-class-user.php on line 111

-Max

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Aug 7, 2012 - 5:07 am

Whoops -  typo on my part.

When you call the SP function it needs to pass $current_user->ID - not the entire object.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Maximillion
Member
sp_UserOfflineSmall Offline
Aug 7, 2012 - 9:40 pm

THANK YOU!

Got it working. I was wondering. sine I'm essentially making an info widget for the person on the site. How can I add the equivalent of these calls (from the forum)

 

In these two I can turn off the title part off when I show the ranking. I also notice the forum has nice overrides in that it only show the Userrank icon if there is no Special rank icon.

sp_PostIndexUserRank('tagClass=spPostUserRank spCenter&showTitle=0');sp_PostIndexUserSpecialRank('tagClass=spPostUserSpecialRank spCenter&showTitle=0');

As for these three - i just want to put that info in a widget also!

sp_PostIndexUserPosts('tagClass=spPostUserPosts spCenter', __sp('Posts: %COUNT%'));
sp_PostIndexUserRegistered('tagClass=spPostUserRegistered spCenter', __sp('Member Since:<br /> %DATE%'));
sp_PostIndexUserStatus('tagClass=spCenter spPostUserStatus', __sp('Online'), __sp('Offline'));

Thanks in advance for any help!

-Max

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Aug 8, 2012 - 9:38 am

Afraid we don't currently have template tags that currently return any of those data items. And the problem with using those actual functions is that they would be out of context of the data object they need and will return nothing.

I can certainly talk it over with Steve to see about offering a custom template tag that does return such data..

andy-signature.png
YELLOW
SWORDFISH
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: 619
Members: 17362
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625