here is a very simple function that should do it:
function loginout_button_wpa89153($echo = true){
if (is_user_logged_in()){
$url = wp_logout_url(get_permalink());
$anchor = "Logout";
}else{
$url = wp_login_url(get_permalink());
$anchor = "Login";
}
$button = '<a href="'.$url.'" class="join-button">'.$anchor.'</a>';
if ($echo)
echo $button;
else
return $button;
}
Related Posts:
- Change the footer text on the login page
- Copyright info change in Theme Child PHP
- Add footer.php to WordPress child theme
- Successful or Error Message after running mysql code in functions.php
- Login/logout in header
- getting logged in user info (wp-load.php) from parent directory
- How to display login form anywhere, when user isn’t logged in, without redirecting?
- Display Data in Table from External Database in WP using Shortcodes
- Need help for some PHP code
- Can’t log in to WordPress wp-admin after adding code to functions.php
- How to preload header logo image in WordPress? like what’s the code and where do I put it?
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- How to put 2 php codes in functions.php without site crashing
- Restrict wordpress access to logged users only
- Menu not updating for logged in users after redirect
- how to use auth_redirect() redirect visitor to login page if they are not login when they click account and order page?
- Refresh page after login with litespeed cache
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- is_user_logged_in() not working in homepage
- how to create twitter card without plugin in wordpress website?
- How to set and use global variables? Or why not to use them at all
- How to Add Image to WordPress RSS-Feed with no Plug-in?
- Enqueue Javascript Correctly for 3.5
- How to add active class to custom menu using while loop and wp_list_pages
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- automated tests as a user?
- WooCommerce – Display variation custom field value [closed]
- Restrict WordPress File Type Uploads by User Type
- New Plugin Review
- Problems with function on function.php
- Woocommerce HTML email option unavailable
- Use template for posts with a particular category grandparent
- How to slow down server response
- Click loads template via ajax
- Randomise upload filenames (or another solution to hide the original image URL from theft?)
- jQuery not defined
- Use menu link or onClick to set a variable
- Automatically remove a canceled order in Woocommerce
- WordPress add post format support not working
- How to remove the cufon script from Dzonia Lite theme [closed]
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Create highly customized submenu (possibly using wp_list_pages)
- $wpdb->wp_users returning empty value for
- WordPress Custom field Colors
- php syntax : [ && ] between commands [closed]
- Insert custom PHP head above in WP pages
- How to use theme function in post/page?
- esc_url( ) won’t use https
- Content filter won’t work
- Where is this function’s callback getting its arguments from?
- Why does the post_type_link hook everything twice?
- Warning: in_array() null given in PHP function
- Use post ID in functions.php file adminside
- How to: Conditionally Enqueue JS and Stylesheets, for Custom Post Type (Single and Archive Templates)
- use loop to return blog details
- How can I count ACF sub_field with a certain value
- change the default order of posts only for specific categories
- Fetching Initials of the Commentator in the WordPress Website
- Adding function to child theme’s function.php
- Custom posts password protect
- How to get post category list as select in front-end?
- How to use functions [closed]
- Splitting the_content() by size?
- Is it legal to redefine wp_password_change_notification in a mu plugin?
- Function to call either single post or category
- WP Container Displaying Only on First Page of Archive
- Updating Metadata with Shortcode
- can’t load .po file in functions.php
- Woocommerce – Exclude variation attribute on specific variation
- How do I add a function to parent theme
- Are there any drawbacks on opening a session_start in functions.php and header.php?
- Create shortcode for metabox gallery
- Log out without confirmation request (nonce)
- Add Pre-Defined Value to Click Counter in WordPress
- How to move a post from one category to another
- Show data obtained from a function and place it in a shortocode function
- How to override theme’s public static function inside of a trait?
- Infinite loop when logging out using custom login form
- Delete empty title_tags, find a h1 heading and echo it
- how to use 2 index.php file One for mobile and one for desktop
- WP_Query To Display Product Of Brand On Taxonomy Page
- ajaxurl usage for a custom function
- oembed facebook link?
- Open/closed function [closed]
- How can I export data without using any import/export plugin
- Search for images that width and height is more than 500
- add a value to an external link query in searchform
- Add disclaimer before certain posts and pages
- wordpress ajax return 0
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- site_url() returns with additional backslashes
- Overwriting a Shortcode
- Search box background on a different page template
- WP Ecommerce: Display the “Order Notes” as column in the Sales Log [closed]
- A next page function with shortcode?
- What is the wrong with this function to enqueue the scripts and styles to the theme? [closed]
- Warning: Attempt to read property “term_id” on int – Woocommerce
- a problem in class in class-wp-hook.php
- change title of page dynamically
- Custom plugin doesn’t show in admin menu – when code added, displays an empty page