It’s simple, use the function is_user_logged_in
:
<?php if ( is_user_logged_in() ) { ?>
<a hef="link-for-logged-users"></a>
<?php } else { ?>
<a hef="link-for-users-not-logged-in"></a>
<?php } ?>
See here http://codex.wordpress.org/Function_Reference/is_user_logged_in
Related Posts:
- Add multiple custom fields to the general settings page
- Adding fields to the “Add New User” screen in the dashboard
- How to add first name & last name to default registration form?
- Create new user without password
- How to display error messages using WP_Error class?
- How to override WordPress registration and insert an auto-generated username?
- Restrict user registration to emails on a single domain
- Remove default user registration, login and subscriber profiles
- WordPress registration and contact form 7 [closed]
- Custom registration URL lost when user makes signup mistake
- List of Body Classes Generated by body_class()
- How to add custom fields to my custom registration form
- Display alert on successful user Sign Up
- Change label for registration Fields
- Multisite 404 on pages – rewrite error breaks database
- Registration Hooks don’t appear to be working
- Trying to register script in footer
- Adding additional roles on registration
- What is the better for call files: bloginfo() or echo esc_url()?
- call wp_insert_user in custom class doesnt work
- How to setup a popup registeration page in wordpress with function.php
- wp_enqueue_script() not working
- Allow user select role in wordpress default registration without plugin
- Hide ‘add to cart’ when certain value in dropdown is selected
- Best practice to call a function from a button-link?
- Unable to login after registration
- How do I make a custom “Read More Blogs” button for my blog page
- WordPress Toggle Menu has stopped working
- button to toggle css styling / div visibility?
- Set display name from nickname with register process
- Restrict certain roles registrations by domain
- Changing the register url is not working
- Problem in outputting shortcode
- Problem in shortcode outputting content
- Mail function not working with user accounts
- Register a widget area when a theme option has been saved?
- Button generate a random URL [closed]
- Help finishing script to export WP user data when form submitted
- Why use if function_exists?
- Include files in child theme functions file
- Check if post is being published for the first time, or is an already published post being updated
- How to get woocommerce inventory status [closed]
- Implementing DNS Prefetching with WordPress
- Why do I get Fatal error: Call to undefined function get_most_recent_post_of_user()?
- Enqueuing External Javascript functions.php
- Checked() showing up twice in custom fields
- Date/time limitation of posts where function must be executed
- Gravity Forms field entries into wp_query loop [closed]
- Remove the deleted users avatar from list
- Update Content based on expiration time or queued processing
- Adding to fontawesome-webfont.woff2 to boost website speed
- How to enable template page only for a post id page
- Having issues with a foreach inside of a shortcode with ACF gallery
- Remove after images
- Is there an alternative to get_template_directory_uri()?
- Word Press – Dynamic Content [closed]
- Get First Child Page ID or Permalink in WordPress Admin
- Footer disappears when using the_content ( )
- Get page id or status by private pages?
- Categories as main menu items and subcategories as nested lists
- woocommerce change currency per category [closed]
- How to override woocommerce.css?
- Connecting to a 2nd DB gives me no results when querying
- Including php files within template
- Author Date Function not working as expected [duplicate]
- Add_filter when value is no variable?
- The Loop not looping?
- I can’t seem to install Font Awesome locally [closed]
- functions.php and conditional tags
- how to make has_block() see inside blocks too
- add_theme_support( ‘title_tag’ ) is not showing title on index.php
- Tracking the number of shortcodes for a list?
- How to print the current post depth as update notification?
- How to safely edit functions.php
- Changing the text of Upload/Insert on Posts and Pages Screen
- remove edit link only for published post and pending post
- When are the user meta fields created in the database? Admin vs Woo API REST
- is_product_category(‘Services’) not working
- How to automatically add counted number to navigation menu items?
- Insert Modal on user first login
- Trying to load JavaScript only on pages within a PODS category/ custom post type
- What is best practices to move the following code into a function?
- Correct way of Enqueue self hosted fonts in sass project
- function syntax is off,
- Language Switch Function
- Change category checkbox into radio button [duplicate]
- How can I include user meta information in the resulting array of a WP_User_Query?
- How to add next height number in Order Attributes inside the Add new page. [duplicate]
- Show the online status of the current post’s author
- Functions.php in child theme that loads CSS file breaks website
- How does child theme functions.php work with parent theme functions.php? Is it like CSS? [duplicate]
- restrict access to specific urls on a specific period of time
- Change conditional tag in wordpress without editing the core files
- Need a functions that adds (adm)/(mod) if current user is admin/moderator right after their username
- Add title & subtitle to shortcodes
- clickable title of 2 post on mainpage USING functions.php
- Custom Post Type Search
- How do i set global variable in a function in wordpress functions.php
- Working function() doesn’t execute when triggered by WP CRON
- post_row_actions filter from parent theme not executing in child theme