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 25, 2012 - 3:12 pm

I replaced the code snippet like this

add_action('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;
        if(function_exists('sf_pm_tag')){
            wp_mail('me@home.de', 'PM_tag_Ex', print_r("sf_pm_tag() existiert!",TRUE));
        }
//        sf_pm_tag(TRUE, FALSE);
        $pm = sf_pm_tag(FALSE, FALSE);
        echo 'In Deinem Posteingang befinden sich '.$pm['count']. ' ungeöffnete Nachrichten';
        wp_mail('me@home.de', 'PM_tag2', print_r($pm,TRUE));     ?>
        <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
}

The resut is: the function exists in this place but returns some invalid array content - the same as before mentioned.

I've tried the same in V5.1.2 with sp_pm_inbox() and it is exactly the same .function exists, array invalid.

Obviously, it is a problem of validity of data. Any idea where I can call the function with valid array return?

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

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

not sure what you are trying to do...  if the user is not logged in, the count should be -1...  but the code in 4.5.1 is different than 5.x...

what error are you getting?

perhaps after the call, add some debug code...

ashow($pm);

or

print_r($pm);

and lets see what is returned...

Avatar
Dietmar Herian
Member
Free Members
sp_UserOfflineSmall Offline
Jul 27, 2012 - 8:57 am

I try to use the 'wp_login' hook to present a message to the user that he/she has got PMs in the box. It works on a static call in a side template but does not respond proper Array under the hook. I do not get any error message.

I do the debugging via wp_mail() because this is a remote server and I get it printed. The response for $pm is in both cases V(4.5.1 and V5.1.2) the same:

Array

(

    [count] => -1

    [url] =>

)

The first debug email just returns a string to indicate that the function exists in this place. I also tested when the hook event takes place - it is at the end of log-in. The user should be logged in at this time. But with regards to your answer, it seems like this is not yet the case. As always, the WP reference description is not very clear with that.

But wouldn't that be a nice feature to add to the PM-Plugin. Many blog users do not necessarily go to the forum to check wether they have PM(s) or not. This way, the blog owner can make sure they do not miss any.

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

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Jul 27, 2012 - 9:35 am

sorry, still not sure what you are trying to do...

the hook you are using, wp_login, is after the sign on process per se, but its before the page reload of logging in... so not sure how or where you think you are going to display the tag...  any output would not show up anyways...

after the login code completes, which is later/after the hook you used, the login redirect takes affect and the user is redirected somewhere...  so any output you attempt to make will not show up...  also, the wp global variable for the user is not set up until that page redirect either...

so not sure what you are trying to gain with the tag on the login hook vs the sidebar which will be display on the login redirect (assuming its to front end)....

where ever you want to display the pm tag, it needs to actually be on a page load, not some intermediate wp logic step...

Avatar
Dietmar Herian
Member
Free Members
sp_UserOfflineSmall Offline
Jul 27, 2012 - 11:05 am

I was hoping to display it via a fancybox inline which is a popup window, anyhow.

But this does not seem to work and what I understand now is, that the user is not fully logged in at this moment and therefor the information for sp_pm_inbox() is not available at this place.

Then I 'll try it setting a globally availbale marker that a user has just logged in and call sp_pm_inbox() after redirection has ended on some page. Since the page template is always the same, this should give me the result I am looking for.

Thanks for clarifying.

But tell me one thing: where do you get your more detailled information about the hook from? Is there a second source? I am not very happy with the WP actions/filters reference. It is by far too short and not precise in what the hook or filter is doing - besides the huge number of undocumented items. I am always trapped in things not being completed or data not available. How can one know? Looking into the WP core code seem to be the only possibility.

"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 27, 2012 - 11:15 am

" Looking into the WP core code seem to be the only possibility."

That's what I nearly always end up doing...

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: 17363
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625