2013-03-24, 11:30 PM
2013-03-25, 12:10 AM
Why can't you just use {$mybb->user['username']}? What are you trying to do?
2013-03-25, 12:20 AM
(2013-03-25, 12:10 AM)Fábio Maia Wrote: [ -> ]Why can't you just use {$mybb->user['username']}? What are you trying to do?
Make a custom userscript.
2013-03-25, 12:54 AM
The username is displayed on all forum pages inside the welcome block (in most themes anyway). If you're able to rely on that, you can grab the username quite easily:
Or using jQuery:
This assumes a default MyBB installation.
var username = document.querySelector('#panel strong a').innerHTML;
Or using jQuery:
var username = $('#panel strong a').html();
This assumes a default MyBB installation.
2013-03-25, 12:51 PM
(2013-03-25, 12:54 AM)Fábio Maia Wrote: [ -> ]The username is displayed on all forum pages inside the welcome block (in most themes anyway). If you're able to rely on that, you can grab the username quite easily:
var username = document.querySelector('#panel strong a').innerHTML;
Or using jQuery:
var username = $('#panel strong a').html();
This assumes a default MyBB installation.
TypeError: Cannot read property 'innerHTML' of null
get stack: function () { [native code] }
message: "Cannot read property 'innerHTML' of null"
set stack: function () { [native code] }
__proto__: Error
Figured it out.
var myname = $('div.welcome strong a span strong').html();
2013-03-25, 01:18 PM
Like I said, the code assumed a default installation. Your theme is different, hence why the selector returned null. Glad you figured it out yourself.