Multiple use wp_logout_url() on page cause ‘header already sent’ error after submit form
Multiple use wp_logout_url() on page cause ‘header already sent’ error after submit form
Multiple use wp_logout_url() on page cause ‘header already sent’ error after submit form
You can try something like this and implement it in your own case <?php if ( is_user_logged_in() ) { $extraClass = “hide-button”; } else { $extraClass = “”; } ?> <a class=”<?php echo $extraClass;? href=”#”>”>Button text</a> and give the new class a styling like “display: none;” or something
“PRIMARY” and “secondary” menu bar really don’t mean anything when used out of context and without explanation. However, (guessing a lot) if your menus are constructed consistently you should be able to find the ‘name’ of the second menu and add a condition like (overly formatted for readability): if ( is_user_logged_in() && ( $args->theme_location == … Read more
You shouldn’t be echoing anything directly from your functions.php. Doing so will prevent redirects. Remove line 226 and you should be good to go. You might want to replace that whole remove_admin_bar with something better coded (or a plugin even).
home_url() will accept a parameter that will be used in the creation of the URL. The bare minimum solution would be: add_action( ‘wp_logout’, create_function( ”, ‘wp_redirect(home_url(“/path/to/page”));exit();’ ) ); site_url() will also accept the same parameter and may be (probably is) a better choice. I believe that using either of those will make the link dependent … Read more
To add a menu item to the end of a nav menu you can use the wp_nav_menu_items hook. Combine that with is_user_logged_in() and you ought to have it. function add_last_nav_item($items) { if (!is_user_logged_in()) { return $items .= ‘your login link’; } } add_filter(‘wp_nav_menu_items’,’add_last_nav_item’); As far as translation, I assume that qTranslate uses the standard translation … Read more
Change the filter hook to wp_nav_menu_{menu-name}_items, so it will only run on a specific menu. For example, if the menu name is “Secondary”, use the hook wp_nav_menu_secondary_items, or if the menu name is “Top Navigation”, use wp_nav_menu_top-navigation_items (replace spaces in the menu name with dashes). Your updated code, assuming the menu name is “Secondary” (the … Read more
You are using PHP tag inside echo statement. Try this: echo ‘<a href=”‘.wp_logout_url().'” title=”Logout”>Logout</a>’; If you want to redirect to any specific url then you can pass it as argument of wp_logout_url. Check official documentation of wp_logout_url. Note : It is recommended to return value from the shortcode function rather than directly displaying it. Try … Read more
get_permalink will fetch the URL of the current post within a loop. If you call it on an archive page, then what WP thinks is the “current post” is actually the first post that you are about to loop through and so you end up with that post’s permalink rather than the current page’s URL. … Read more
First: Your question does not indicate that you have made any programming attempt to get this done. Code to do this…. if ( is_user_logged_in() ) { // your ‘entire-menu code’ or ‘logout’ link for logged in user } else { // your ‘Entire-menu code’ or ‘login / Register’ links for logged out user } Second: … Read more