Support Forum
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)
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...
Visit Cruise Talk Central and Mr Papa's World
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)
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...
Visit Cruise Talk Central and Mr Papa's World
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)
1 Guest(s)