12985

How do i redirect non logged in users Wordpress

Question:

I am looking to redirect users who are not logged in on any page of my WordPress website to a /welcome page which will have a sign up form on. This is pretty essential as it is a small social networking site.

I am also trying to do this without having any redirect loop issues so my users can easily get to the /welcome page without any hassle.

Answer1:

Put this in your header.php file

if( !is_user_logged_in() && !is_page( 'welcome' ) ) { wp_redirect( bloginfo( 'url' ) . '/welcome' ); exit; }

Hope that helps

Regards

Dan

Recommend

  • Better to use long or long long in 64 bit
  • What is the Difference between system initialization and update in hybris?
  • Get Yahoo Contact List in C# application
  • wp-query category and has tag
  • Getting the length of an array. Compiler errors.
  • Drop packet with libpcap
  • Issue declaring extern class object
  • C# dynamic support?
  • applying background to first, and every third row in a dynamically generated table
  • How does socketcan handle arbitration?
  • Client-side prediction & server reconciliation
  • Add log separators to all fixtures in unittests
  • Laravel 5.2 Auth::check() on exception pages (layouts)
  • Error Installing Windows 10 development tools for Visual Studio 2015 RC on Windows 8.1
  • C# - Most efficient way to iterate through multiple arrays/list
  • netsh acl setting (need alternative method - registry settings?)
  • TFS 2015 - Waiting for an agent to be requested
  • During installation of Django, why do I keep getting ImportError: No module named django?
  • pillow imaging ImportError
  • SharedPreferences or SQLite Database?
  • Remove final comma from string in vb.net
  • Mysterious problem with floating point in LISP - time axis generation
  • How to know when stdin is empty if it contains EOF?
  • All Classes Conforming to Protocol Inherit Default Implementation
  • Using $this when not in object context
  • Uncaught Error: Could not find module `ember-load-initializers`
  • How to make a tree having multiple type of nodes and each node can have multiple child nodes in java
  • script to move all files from one location to another location
  • Cassandra Data Model
  • Websockets service method fails during R startup
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • jQuery tmpl and DataLink beta
  • SQL merge duplicate rows and join values that are different
  • Codeigniter doesn't let me update entry, because some fields must be unique
  • Proper way to use connect-multiparty with express.js?
  • python regex in pyparsing
  • How to set the response of a form post action to a iframe source?
  • Programmatically clearing map cache
  • How to get NHibernate ISession to cache entity not retrieved by primary key
  • Reading document lines to the user (python)