If the user is logged-in, the function returns before the redirect code lower in the function.
if( is_user_logged_in() ) {
return;
}
Since you want the redirect code to run only if the user is logged in, try this:
if( ! is_user_logged_in() ) {
return;
}
Related Posts:
- Getting paginate_links() ‘end_size’ to display none
- What is the best practice for escaping data URIs?
- WordPress Template Engine?
- Display only text to WordPress loop without loosing the text formatting
- Where exactly do I write define( ‘WP_DEBUG’, true ) in wp-config file
- Making a follow button, Ajax not talking to php
- get understrap pagination to work with custom query
- Replace existing content from specific WooCommerce admin orders list column
- How do I get images (with a thumbnail preview) to show in search results?
- How to display blog images using wordpress in existing project
- How do I translate this string – PHP syntax question
- How to break down importing of feeds
- PHPCS: Strings should have translatable content
- mysqli_real_connect() – authentication method unknown to the client Warnings
- WordPress shows registration link for non logged users
- How to get woocommerce cart content without an action?
- php syntax – how to concatenate properly – echo bloginfo(‘stylesheet_directory)
- how to increase custom post value by one most efficiently?
- multiple if statements [closed]
- Escape post image attachments added to template
- Woocommerce product download URL
- Multiple choice in a custom taxonomy
- Bridging TinyMCE js and WordPress PHP?
- Echo URL of large version of Featured Image
- Get_avatar filter?
- WordPress custom login form using Ajax
- Remove price from Woocommerce variable product dropdown menu
- WP dynamic featured image – Can’t get second featured image url
- Why is my cookie not unsetting upon logout? [closed]
- How to hide products that do not have an image from a slider carousel for an ecommerce webpage?
- How to remove role=”navigation” from all nav elements?
- how to query a post based on previous page post ID
- How to use $_GET function WordPress backend
- How to set variable, pass it to a partial file and remove it after?
- wp_dropdown_pages auto submit
- WooCommerce Tabs [closed]
- Limit checklist by the current user
- How to loop through all the attached images in a post, and get their url one by one
- Use Tags to initiate Search
- Show About and Contact Us page when they’re clicked in the top menu.
- single.php with different look by category
- Displaying posts based on category
- Changing the color scheme based on the url visited
- How to send form data from WordPress (Meta Box) to an OData service?
- Convert a string into a decimal number for use in query
- How to get specific attribute from DB
- customize woocommerce templates and display store on home
- Delete or edit postmeta with specific meta_key?
- Post repeated when opening in overlay, how do I solve this? [closed]
- Woocommerce: remove total sum from new order’s email [closed]
- Trying to display text in a block in a plugin page
- Some menu items wont budge
- Removing “Powered by” footer using child theme PHP [closed]
- custom post type with role Vendor
- how to hide or disable some part in specify page
- Include a file that has a function in it
- Kohana Frontend, WordPress Backend
- making my own “related pages” / “pages you might like” section
- apply_filters with several different values?
- Show ranking based on post id
- How do you create a custom category widget that you can style?
- Add Custom Category Description When Empty
- echo cutom css code to WordPress page template file ? is this safe?
- Contain multiple page templates in one PHP custom template file in WordPress?
- url not using query string no longer working
- How do I reopen the (Popup Maker) after entering the correct password for a password protected page?
- Custom plugin: how do I call a PHP file if settings option is set to true?
- How to edit button permalink inside function.php using a child theme?
- How to switch between two primary menus (programatically0
- Why am I getting syntax error, unexpected ‘endwhile’ (T_ENDWHILE) on single.php
- How to add a full working piece of website already coded, to a large scale Website design project?
- Elementor to custom wordpress page
- custom post type not showed with bootstrap 4 modal and template part
- Send email to users when they get new followers
- Conditionally change WordPress core language
- Remove item from post_meta array via AJAX
- Shortcode just with a php code
- add menu page in loop menu order
- CSS loading as empty file in Custom Theme
- Calling WordPress hook from within a class: call to undefined function error
- wp_send_json erase last value
- PHP array to jQuery array ” Uncaught SyntaxError: Unexpected token < "
- I want show only data for today
- How can I customize a WordPress theme before it’s downloaded?
- How to only fetch certain Tag ID’s
- rewrite_rule – working fine but broken for pagination
- AdWords API with WP
- Add title and caption to thumbnail image on mouseover
- Postmeta not saving
- WordPress wp_remote_post() sending informaiton to Redmine REST API
- Missing items on page
- WordPress rewrite question
- WordPress blog set up
- Cannot get custom javascript to execute on page
- How to declare a variable at the bottom of the page and use its value at the top?
- How can a ‘scripts’ directory be hooked into wp_head();?
- Display Current Time using shortcode
- WP and Laravel integration (Updated) [closed]
- Custom Post Type doesn’t have template content when creating programmatically in PHP but does when created in WP Admin
- How can add alt tag in following code. Image are showing dynamic in wordpress