Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
plugins-topic
Template Tag PM inbox
Avatar
Dietmar Herian
Member
Free Members
sp_UserOfflineSmall Offline
Jul 23, 2012 - 4:16 pm

Hi SP team,

my first attempt to use a template tag seems to be not successful. I just tried to put

<?php sf_pm_tag(true, false); ?>

in one of my side templates and also the shortcode version

[sf_pm_tag]

but both won't work.

From the code version I get a fatal php error 'call to a undefined function in ...' and from the short code version I get nothing.

The plugin 'Template Tags' is installed and activated. Am I missing something?

"Computers in the future may weigh no more than 1.5 tons."
(Popular Mechanics, US-Technik-Magazin, 1949)

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 23, 2012 - 4:29 pm

That's old V4 syntax as far as I can remember.
And PM template tags will be in the PM plugin.
But... I am not sure which one replaces this in V5 and I am going to have to ask...
So - someone will come back to you.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Dietmar Herian
Member
Free Members
sp_UserOfflineSmall Offline
Jul 23, 2012 - 4:46 pm

Thanks for your quick reply.

I found out my version mistake meanwhile - tried

sp_pm_do_inbox()

but likewise to no avail.

Hope one of the experts can hint me to that.

"Computers in the future may weigh no more than 1.5 tons."
(Popular Mechanics, US-Technik-Magazin, 1949)

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 23, 2012 - 5:02 pm

I think you found it except it is just sp_pm_inbox()

andy-signature.png
YELLOW
SWORDFISH
Avatar
Dietmar Herian
Member
Free Members
sp_UserOfflineSmall Offline
Jul 24, 2012 - 11:17 am

Yes, it is! Works pefect for me.

Occassionally, you could let me know how this translation from function name to tag name works - or is there a reference list somewhere? Maybe, I have to wait for the official docs.

"Computers in the future may weigh no more than 1.5 tons."
(Popular Mechanics, US-Technik-Magazin, 1949)

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 24, 2012 - 11:26 am

We are slowly compiling them and I did think that one was actually done but I was wrong.
The names of the functions in the actual template tag files themselves are not public names. The public names are contained in the main plugin file in each case. If it has a 'do' in the name then it s the wrong one basically!

andy-signature.png
YELLOW
SWORDFISH
Avatar
Dietmar Herian
Member
Free Members
sp_UserOfflineSmall Offline
Jul 25, 2012 - 10:01 am

Sorry to bother - but I still need some help with this. The tag works fine when used in a side template.

Now I am trying to invoke it triggered by a WP login filter like this

add_filter('wp_login', 'PN_check', 10, 3);

function PN_check($user, $username, $password){
   ?>
    <div style="display:none" class="fancybox-hidden"><div id="popup" style="width: auto; padding: 5px">
    <?php
        global $wpdb;
//        sf_pm_tag(TRUE, FALSE);
        $pm = sf_pm_tag(FALSE, FALSE);
        echo 'In Deinem Posteingang befinden sich '.$pm['count']. ' ungeöffnete Nachrichten';
          ?>
        <a href="<?php echo $pm['url'] ?>">Zum Posteingang</a>
<!--<a href="#" onclick="javascript:jQuery.fancybox.close();return false;">Close this window</a>-->
</div>
</div>
<a id="fancybox-auto" class="fancybox" href="#popup"></a>
<?php
return $user;
}

in my theme's functions.php so that users should get a popup message when logging in.

But the returned string $pm is empty in this environment

Array

(

    [count] => -1

    [url] =>

)

 

How comes? Is the tag not valid here? Is it only valid in side templates?

But users can log in and out at any time when the site is up.

"Computers in the future may weigh no more than 1.5 tons."
(Popular Mechanics, US-Technik-Magazin, 1949)

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 25, 2012 - 10:31 am

there os no such function as sf_pm_tag(). Were you not using sp_pm_inbox()?

Just for the record, WP filters are not intended to be used for displaying content directly like that. All content should be compiled up and then returned, in this case, in the $user variable. Except that would create chaos. 'Actions; should really be used for this sort of thing instead of 'Filters'.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Dietmar Herian
Member
Free Members
sp_UserOfflineSmall Offline
Jul 25, 2012 - 11:52 am

Sorry, forgot to mention - this one is back to V4.5.1. And the sf_pm_tag-function returned a proper array in a side template. I'd like to try this first in my local (old) install rather than in the remote server which is already SP5.1.2.

You are right with filters and actions - this was just 'quick and dirty' to see wether it works.

What about validity? If I were using sp_pm_inbox in a WP login action hook, would it return proper array content?

"Computers in the future may weigh no more than 1.5 tons."
(Popular Mechanics, US-Technik-Magazin, 1949)

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jul 25, 2012 - 12:06 pm

As far as I am aware it should work.
Your problem may be one of the code being out of scope. Check for the function using function_exists() to see if it is actually available for use from that place.

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