Help with "is user logged in"
-
Hi there,
im trying to set up a forum with wordpress: https://www.die-dunkle-wache.de/forum (i never used WordPress or css before)
I installed the “bbpress-login-register-links-on-forum-page” Plugin and tried to script it…i failed.
I want to hide the Plugin (Login,Register,forgotpsw-links)if a user is already logged in.
This is the default:<?php function bbpressLoginRegisterLinksOnForumPage() { echo '<div class="bbpressloginlinks" style="float:right;padding-right:20px;">'; $login_url = site_url( 'wp-login.php' ); echo "<a href='$login_url'>".' Log In '.'</a> '; $register_url = site_url( 'wp-login.php?action=register' ); echo " <a href='$register_url' style='margin-left:20px;'>".' Register '.'</a> '; $lost_password_url = site_url( 'wp-login.php?action=lostpassword' ); echo " <a href='$lost_password_url' style='margin-left:20px;'>".' Lost Password '.'</a> '; echo '</div>'; // class of "bbpressloginlinks" } add_action('bbp_template_after_forums_loop','bbpressLoginRegisterLinksOnForumPage'); add_action('bbp_template_before_pagination_loop','bbpressLoginRegisterLinksOnForumPage'); add_action('bbp_template_after_single_forum','bbpressLoginRegisterLinksOnForumPage'); add_action('bbp_template_before_forums_loop','bbpressLoginRegisterLinksOnForumPage');
and this is what i did (https://codex.www.ads-software.com/Function_Reference/is_user_logged_in):
<?php if ( is_user_logged_in() ) { } else { function bbpressLoginRegisterLinksOnForumPage() { echo '<div class="bbpressloginlinks" style="float:right;padding-right:20px;">'; $login_url = site_url( 'wp-login.php' ); echo "<a href='$login_url'>".' Log In '.'</a> '; $register_url = site_url( 'wp-login.php?action=register' ); echo " <a href='$register_url' style='margin-left:20px;'>".' Register '.'</a> '; $lost_password_url = site_url( 'wp-login.php?action=lostpassword' ); echo " <a href='$lost_password_url' style='margin-left:20px;'>".' Lost Password '.'</a> '; echo '</div>'; // class of "bbpressloginlinks" } add_action('bbp_template_after_forums_loop','bbpressLoginRegisterLinksOnForumPage'); add_action('bbp_template_before_pagination_loop','bbpressLoginRegisterLinksOnForumPage'); add_action('bbp_template_after_single_forum','bbpressLoginRegisterLinksOnForumPage'); add_action('bbp_template_before_forums_loop','bbpressLoginRegisterLinksOnForumPage'); } ?>
but when i use it the forumpage gets empty
Hope you can help me
Best Regards,
Gotzak
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Help with "is user logged in"’ is closed to new replies.