You can use the session functionality in PHP to determine if a user is logged in or not.
<?php
session_start();
if (isset($_SESSION['logged_in']) && $_SESSION['logged_in'] === true) {
$link = '/my-account.php';
$text="My Account";
} else {
$link = '/login.php';
$text="Login";
}
?>
<a href="<?php echo $link; ?>"><?php echo $text; ?></a>
Related Posts:
- Login to wordpress by clicking a link and specifying usernaname and password in url
- Programmatic Login from 3rd Party site
- Use DOMDocument with ob_start breaks my HTML code
- Cannot access wp-admin/wp-login.php (WordPress backend) anymore, what could be wrong?
- How to change redirection route to a php page for making it only accessible by logged-in members?
- How to debug my custom login form looping intermittently
- getting logged in user info (wp-load.php) from parent directory
- selected option if current category is the value
- How to remove ?wp-mce-4103-20162941
- Customize position of social icons in upme plugin [closed]
- Why Won’t My Inputs in a form with a Get method work together?
- parts of url disappear when using # inside href=”” [closed]
- Settings API callback function inserts html quotes from nowhere
- Input data from email form not going to JSON file
- How to get the value of input hidden html from text editor to custom page template?
- Different post styles depending on category
- How create a Shortcode with hover and complex options
- How do I remove the product thumbnail link from a specific div in Woocommerce? [closed]
- Dot is not added at the end of href
- WordPress Multiple Navigation bars
- Position banner to right of logo in header – messed up my header file
- Commenting out unwated CSS/scripts in HTML with PHP
- Are all hooks/functions tied to Kses meant for sanitization?
- How to separate HTML and WordPress files
- Add .htm extention to a custom taxonomy
- Problem with login form
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- How do I add a custom css to all posts without affecting homepage css? [closed]
- Make PHP work with HTML tags
- Log in / Log Out Custom Button
- Noscript not working as it should in wordpress site
- Show latest posts in a plain HTML website custom widget [closed]
- Should `wp_login` be used since it’s deprecated?
- How to convert select to HTML with PHP tags inside of it [closed]
- How to redirect users based on role and content of redirect_to?
- Change CSS based on is_user_logged_in
- Is this spyware on my site or a real Java update?
- Syntax error when I try to insert my loop into an unordered list? [closed]
- How to display login form anywhere, when user isn’t logged in, without redirecting?
- How can I open up my administrative panel to everyone?
- How to make modifications only to certain elements of an HTML string on the server-side?
- Wrapping a Sidebar within
- Search WordPress using static html page
- Hide HTML element (by class or ID) with PHP
- Add Codepen animation as Preloader to WordPress
- Path for php file for inserting data through html form
- Function returns text instead of html [closed]
- Printing HTML codes
- Widget back end radio button issue
- HTML escaping data with ajax requests
- How i can get post data from database when i am getting post id from url in wordpress
- How to retrieve the data from the sever and displaying it in a page?
- php within html within php
- How to execute html code inside php?
- How to remove coupon dropdown feature
- Add data-id attribute to child page links
- Add shortcode in my div
- Location of core code for database connection and get_header
- Adding a line of text to php code
- WordPress plug-in for dynamic download link?
- HTML table attributes ignored
- php esc_html_e with an html link inside not working
- Add html link in functions.php files of the theme
- Using ob_start and ob_get_clean with wordpress shortcode
- How to edit HTML of my website on WordPress? [closed]
- WordPress wp-admin redirect and exception
- How to remove the h6 tag for the entry-category Class
- Override user-edit.php to design own profile page
- How can I add a new row in a separate database when someone registers via WordPress?
- wp_insert_post() with HTML tags using PHP
- How to rename woocommerce-billing-fields
- Prevent redirect to wp-login.php
- PHP contact form not redirecting [closed]
- Creating an image from a custom field
- How to Schedule Cronjobs for start of every month and year
- Where can I find the inline-css of my theme header?
- Handling PHP/HTML inside the output of a shortcode function
- Make textarea required. Help [closed]
- One account with multiple logins
- Admin submenu issue with PHP not detecting two strings as equal
- Lost in trying to create user database system
- WordPress forms submissions and PHP files
- Trying to display text in a block in a plugin page
- Menu Custom Data Attributes
- How to add post meta in while loop?
- Adding function to child theme’s function.php
- Highlight the links without using dropdown
- Illegal string offset error in wordpress theme options textarea
- How to turn each phone number within the $content to a telephone link?
- Creating custom page template from existing PHP site
- Shortcode to log user into current URL
- wordpress site – using custom database and PHP
- How to use the checked() function to check for a non-empty var
- Calling function in loop causes repeat data
- Remove   from the_excerpt
- How do I access post_meta key with php?
- Find out last 7 days of upload images, last week uploaded image from Gallery and display them in different pages
- Separate array output into a
- Website completely messes up when logging out
- Need help removing […] after excerpt