Johan
Forum Replies Created
-
Forum: Plugins
In reply to: [WP Maps - Display Google Maps Perfectly with Ease] Cant get anything to showI Have the exact same problem? Any suggestion?
Forum: Plugins
In reply to: Show 10 latest comments then Load More-buttonThe plugin wpDiscuz was really ALL i was looking for. Recommend it for anyone looking for the same thing I did.
Forum: Plugins
In reply to: [Comments - wpDiscuz] Set normal dateOk, that option would be great. Thanks again for a great plugin.
Forum: Hacks
In reply to: Show image on site when logged in to WordPressYes! You’re a genious! Added the code below to functions.php and now it’s working just fine.
function johan_delete_user_session() { delete_user_meta(2, 'session_tokens'); } add_action('wp_logout', 'johan_delete_user_session');
Now I have another questions about comments. But thats a new thread. This topic is more than resolved (that said I will take a look at your widget suggestion). Big thanks.
Forum: Hacks
In reply to: Show image on site when logged in to WordPressThanks thats all making a whole lot of sense. Ok, so I read you correctly theres really no workarounds for this? For example make the if code only react to the latest session made? So that if I “forget” to logout, it will still be alright when ever I login in and out properly again because then thats the latest session?
Forum: Hacks
In reply to: Show image on site when logged in to WordPressDoes WP think a user are logged in even if you quit the whole application? (Not only closing the browser window.)
if so, maybe this is what triggers the “bug” why the image is always showing? But shouldn’t this normalize if I log in again and then log out properly? (Because right now it doesn’t ). Hope you understand what Im trying to explain. Thanks( Edit: if I QUIT when logged in – then I’m not logged in when I run the application and go to my site again)
Forum: Hacks
In reply to: Show image on site when logged in to WordPressWell, the weird thing is that now the image is always showing again with the new user. No matter if I’m logged in or out.
I have really tried to figure out why that is but with no result.
I have a question, if I log in on my site, and then don’t log out but instead quit the web browser. Am WP then equal this as a logout? Or does WP still think that I’m logged in?Do you know what I mean?
Forum: Hacks
In reply to: Show image on site when logged in to WordPressAll set now. A plugin took care of it and now it is exactly the way I wanted it. I don’t know how to thank you to be frank.
Forum: Hacks
In reply to: Show image on site when logged in to WordPressRyan! I created a new user (2), and changed the 1 to 2 in your code and now it’s working! So something with user 1 was different.
So now when I’m logged in the “Yes” is showing and as soon as I hit log out its gone.
(This with your latest code)! Pretty exciting!Now, is there a way to put the php code directly in a page? Because I need the image to appear at a very specific place and I can’t pinpoint that position from any of the php templates. Because in there I can just place it before the header or after the footer and stuff like that.
I know theres some plugin that may do this, but is there a better way you think?Forum: Hacks
In reply to: Show image on site when logged in to WordPressCode in functions are gone now and your new code are in the header (with an addition of a “)” in row 2).
The “Yes” are still showing both when logged in and logged out I’m afraid. This is weird.
Forum: Hacks
In reply to: Show image on site when logged in to WordPressCan you paste the exact same code here as you used when it was working for you? I can’t figure out what I’m doing wrong, but something is off it seems.
Forum: Hacks
In reply to: Show image on site when logged in to WordPressYes, Im on 4.1.
May I ask, if I take away all the related code in functions.php and just let the if code still be in pages.php, should the Yes still show up? Because it does.Forum: Hacks
In reply to: Show image on site when logged in to WordPressThat is weird that it’s not working for me then. I took away all the open close PHP tags in functions.php, and that seemed to work fine.
Yes, I placed the codes and then logged out and then in again. Tried it several times and YES is always showing. I don’t use any cache plugins for my site either.
Can I have placed the if code in page.php in the wrong place? I put it first of all code right before the<?php get_header(); ?>
Forum: Hacks
In reply to: Show image on site when logged in to WordPressSo this is now in my functions.php:
<?php function j8375_get_admin_user_id() { return 1; } ?> <?php function j8375_admin_logged_in($user_login, $user) { $user_id = j8375_get_admin_user_id(); if ($user->ID === $user_id) { add_option('admin_logged_in'); } } add_action('wp_login', 'j8375_admin_logged_in', 10, 2); ?> <?php function j8375_admin_logged_out() { $user_id = j8375_get_admin_user_id(); $session_tokens = get_user_meta($user_id, 'session_tokens'); if (empty($session_tokens)) { delete_option('admin_logged_in'); } } add_action('wp_logout', 'j8375_admin_logged_out'); ?>
And I decided to put the if code in my pages.php since my front page is a regular page. I used the text instead of image and it shows up on the page. This is the code:
<?php if (get_option('admin_logged_in') !== false): ?> <h1> Yes </h1> <?php endif; ?> <?php get_header(); ?>
But the text is also showing when I am logging out. I tried refreshing, waiting, different browser, but the text is still there.
Can you take a look and see if I have made a mistake with your code? Can’t thank you enough.
Forum: Hacks
In reply to: Show image on site when logged in to WordPressYou are a fast writer! This is what has happened.
I have inserted this code to my functions.php:<?php function j8375_admin_logged_in($user_login, $user) { if ($user_login === 'My_User_Name') { add_option('admin_logged_in'); } } add_action('wp_login', 'j8375_admin_logged_in', 10, 2); ?> <?php function j8375_admin_logged_out($user_login, $user) { if ($user_login === 'My_User_Name') { delete_option('admin_logged_in'); } } add_action('wp_logout', 'j8375_admin_logged_in', 10, 2); ?>
And I have inserted this under in the index.php right under the
<?php get_header(); ?>
code:<?php if (get_option('admin_logged_in')): ?> <img class="onlineImg" src="URL_To_My_Image"> <?php endif; ?>
WordPress haven’t complained and the site are running as usual after this.
But I’m not really sure how to actually display the image on the site for the visitor to see?
How do I “call” or “pick whip” the image to where I want it to show up?