pmcg911 Posted June 16, 2015 Share Posted June 16, 2015 Hi all I currently have this code in my functions.php to control my footer menu: add_filter('omega_footer_insert', 'my_omega_footer_insert', 11); function my_omega_footer_insert( $settings ) { $year = date( 'Y' ); $siteurl = get_bloginfo( 'url' ); $sitename = get_bloginfo( 'name' ); return "<a href='http://bibliophone.com/about/'>About</a> | <a href='http://bibliophone.com/terms-of-use/'>Terms of Use</a> | <a href='http://bibliophone.com/privacy-policy/'>Privacy Policy</a><br>© <a href='$siteurl'>$sitename</a> $year</p>"; } I want to add a logout link to this, which displays ONLY when a user is registered and logged in. I have this code: if ( is_user_logged_in() ) { echo ' | <a href="<?php echo wp_logout_url( get_permalink() ); ?>" title="Logout">Logout</a>'; } ..but I'm not having mu luck with it because I don't know for certain that it's correct, and secondly I'm not sure where it should be placed within the first bit of code above. Can anyone help please? Thank you! Paul Link to comment https://forums.phpfreaks.com/topic/296853-help-with-my-functionsphp-coding-to-create-a-logout-link/ Share on other sites More sharing options...
Ch0cu3r Posted June 16, 2015 Share Posted June 16, 2015 That functions returns the footer menu as a string, so you cant use echo. You need to concatenate the logout link if the user is logged in. Something like this maybe function my_omega_footer_insert( $settings ) { $year = date( 'Y' ); $siteurl = get_bloginfo( 'url' ); $sitename = get_bloginfo( 'name' ); $footer = ''; // prepend logout link to footer if(is_logged_in()) $footer .= '<a href="' . wp_logout_url(get_permalink()) . '" title="Logout">Logout</a> | '; $footer .= "<a href='http://bibliophone.com/about/'>About</a> | <a href='http://bibliophone.com/terms-of-use/'>Terms of Use</a> | <a href='http://bibliophone.com/privacy-policy/'>Privacy Policy</a><br>© <a href='$siteurl'>$sitename</a> $year</p>"; return $footer; } Link to comment https://forums.phpfreaks.com/topic/296853-help-with-my-functionsphp-coding-to-create-a-logout-link/#findComment-1514096 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.