Unread PM withou admin panel

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is ON
[img] is ON
[url] is ON
Smilies are ON

Topic review
   

If you wish to attach one or more files enter the details below.

Maximum filesize per attachment: 1 MiB.

Expand view Topic review: Unread PM withou admin panel

Re: Unread PM withou admin panel

by axew3 » Mon Nov 11, 2019 11:12 pm

Hello! Yes it is possible to move everything everywhere.
But do you mean you would like to have notification of unread PM overall wordpress (header or where you like) or just in page forum, like it is at moment? Because this feature still has not been added, the pm ajax notification only works on page-forum.
I would like to add it overall wordpress as option as soon. May on plugin 2.0 version, maybe already on next 1.9.9.

Actually you can see the old code, which i and do not look into from long time, that receive ajax into page-forum.php, from phpBB, which is just a simple function that fire when iframe send a request.

Code: Select all

function w3all_ajaxup_from_phpbb_do(res){
jQuery(document).ready(function($) {
if ( parseInt(res,10) > 0 && null == (document.getElementById('wp-admin-bar-w3all_phpbb_pm')) ){
var resp = '".__( 'You have ', 'wp-w3all-phpbb-integration' )."' + parseInt(res,10) + '".__( ' unread forum PM', 'wp-w3all-phpbb-integration' )."';
 jQuery('#wp-admin-bar-root-default').append('<li id=\"wp-admin-bar-w3all_phpbb_pm\"><a class=\"ab-item\" href=\"".$w3all_url_to_phpbb_ib."\">' + resp + '</li>');
 // window.location.reload(true);// this could be a work around for different themes, but lead to loop in this way
} else if (parseInt(res,10) > 0){
	var r = '".__( 'You have ', 'wp-w3all-phpbb-integration' )."' + parseInt(res,10) + '".__( ' unread forum PM', 'wp-w3all-phpbb-integration' )."';
  jQuery( 'li.w3all_phpbb_pmn' ).children().text( r );
} else {
 if( parseInt(res,10) == 0 && null !== (document.getElementById('wp-admin-bar-w3all_phpbb_pm'))){
  jQuery('li[id=wp-admin-bar-w3all_phpbb_pm]').remove();
 }
}
});
}
as you can see, the code append elements searching for/to an html element with ID

Code: Select all

#wp-admin-bar-root-default
so you should change this

Code: Select all

...  jQuery('#wp-admin-bar-root-default') ... 
to match the element you want append to: note, you should also check that what the above code do, it append <li> element, so may you also need to change this, appending another kind of html element instead (maybe a <div>).

If you're able to understand what the code do it's easy to adapt to any of your fits.

If you just want to get the value to display, to simplify, and then you'll adapt as you like, you could do then maybe change the above into this:

Code: Select all

function w3all_ajaxup_from_phpbb_do(res){
jQuery(document).ready(function($) {
// code to display   res   (res = return pm count) where you want
});
}
Same result can be achieved in various ways, will be simplified on next version, where a simple js function that can be placed everywhere, will display PM count.
Also will be added possibility to display forum's pm count overall wordpress, via shortcode that will be very easy to adapt/style for any scope.

Unread PM withou admin panel

by zawin » Mon Nov 11, 2019 6:57 pm

Hello axew3, many thanks for this plugin ;)
I found that in latest version of plugin you support information about number of unread messages in WP admin panel. It's possible to get this information outside admin panel? I want to integrate into theme header file.

Thank you

Top