You can make more readable, like. Small notes at the code. As a hint, the template tag is_page() supports an array of values – is_page( [ 'login', 'register' ] )
.
add_action( 'template_redirect', 'login_redirect' );
function login_redirect() {
// If user is NOT logged in, doing nothing.
if ( ! is_user_logged_in() ) {
return;
}
// This OR (||) this. is_page supports an array of different values.
if ( is_page( [ 'login', 'register' ] ) ) {
wp_redirect ( site_url( '/account' ) );
exit;
}
}
Related Posts:
- Fatal error: Call to undefined function mysql_connect()
- Allow Editors to edit pending posts but not draft ones
- Check php version before theme activation
- How Attackers write script into my php files?
- How to make an meta_query optional?
- How to show only parents subpages of current page item in vertical menu?
- How to remove html comment from source?
- How to use copy() function and paste file in /wp-content/themes directory
- PHP calling AJAX function that relies on passed PHP function values not working
- Need help on WordPress and php
- Looking to exclude blog posts from category Previous/Next buttons
- Automatic Excerpt Not Working
- Best way to create a user programatically
- I think emoji are killing my WordPress site… How can I debug?
- WordPress Ajax Data problem
- Remove all nav menu classes ( but keep useful ones… )
- Hiding a php element from mobile browsers
- How do I turn a shortcode into PHP code?
- ajax_object is not defined when ajax calls the function
- Can I change the contents of a description meta tag generated by Yoast?
- How to filter/hook-into retrieve_password() to filter $_POST[‘user_login’]?
- Sorting Posts | Alphabetical Order
- wp_insert_post not working
- Add htaccess rules with insert_with_markers at beginning of htaccess
- Shortcode content output but not in correct place
- Add a custom stylesheet for BlackBerry
- Storing Array from returned database query and using the array in a new query
- Why my filterable portfolio page work not perfectly between slug button and slug output WORDRPESS?
- PHP variable = get_the_post_thumbnail_url outputting without slashes
- Automatically adding new post categories to menu
- MetaBox body is not showing (the callback function)
- WordPress every page is 404 not found including admin resources
- get author_name from queried post
- Insert term and child term from frontend
- Do wordpress create a new file for each new post?
- post thumbnail, conditions, else wont work
- How to show a users bio on a page
- Add Ajax Hooks and Call from Custom Template PHP
- Why in my theme I can’t see all the statics content under the posts?
- Display all pages – in order
- Backend of the WordPress.com [closed]
- Get Page ID from Backend
- PHP in Edit Post link
- Can a plugin redirect product page based on IF condition?
- How set a custom URL for a new theme file in WP?
- Add class to website based on post taxonomy
- Need php code’s output to display underneath a Divi Module
- woocommerce related product title length
- How to get post ID from button and pass title to Modal
- file_get_contents(includes_url( ‘/js/jquery/jquery.js’ )); not working
- what is the method to echo class attribute inside the i tag? [closed]
- PHP Warning: include(): Unable to allocate memory for pool
- javascript variable to wordpress php variable
- Do I need to edit my theme in order to change the title of my blog page?
- trouble with parse error [closed]
- Do not duplicate posts with multiple categories in multiple loops
- Can’t change website Title on wordpress
- Query for user roles
- Php file that doesn’t recognize wordpress functions
- Set cookie for visitor
- Remove Post if Advanced Custom Field is checked to fix paging
- Is there a way to create a “copy post” link?
- Use of antispambot with $curauth->email
- How to separate product payment and shipping payment in WooCommerce checkout? [closed]
- Add a suffix to the image in the_content()
- add role on WordPress in PHP on a second database
- WordPress single.php get_header not working
- Load more posts using AJAX based on posts inside WP_Query
- Enqueue assets from multiple directories using add_action/do_action
- Can I disable auto increment of WordPress Posts Database to utilize previously deleted records?
- Changing Date Format on Custom Meta Data w/shortcode call
- add ‘publish metabox’ to Gravity forms edit page/form area
- How to redirect (301) trashed post to it’s parent taxonomy TERM ARCHIVE instead of 404 page
- A WordPress Page to display custom database query results
- style.min.css code issue
- How can i iterate through this shortcode array?
- Site doesnt work once PHP changed to 7.1
- How do I prevent a folder from reappearing in my home directory?
- How to detect and make links nofollow in author description
- Making my own admin panel for WordPress
- Run PHP Results inside WP Shortcode
- Styling admin page rows in order of importance (checkboxes)
- WordPress plugin creating sidebar on the theme/page
- Change taxonomy for categories
- Accessing Variables Used In a Plugin Using PHPStorm + XDebug
- How To Customize Position of »add to cart« of WooCommerce on Product Page [closed]
- Show Nav Link To Users Signed In
- Display wordpress post to static website in the footer
- How to echo a different field if another field is empty?
- Remove the_content From Loop
- PHP Puzzle: Unique Styles with PHP loop
- My title is showing after the shortcode
- Display Sale Price Before Regular Price (WooCommerce)
- Load a Header in wordpress
- Trouble figuring out how to get my button to submit comment
- Adding multiple conditional tags in a function?
- Using is home to get content [closed]
- change title of page dynamically
- Custom Filtering date with newsletter
- WordPress critical error after trying to update to 6.2 – Fatal error: Allowed memory size of 268435456 bytes exhausted