You are using an undefined variable in your code ($padeid), it can be causing you problems. Try this code instead:
add_action('template_redirect','wpse16975_check_if_logged_in');
function wpse16975_check_if_logged_in(){
global $wp;
if( ! is_user_logged_in() ) {
$url = wp_login_url( site_url( add_query_arg( array(), $wp->request ) ) );
wp_redirect( $url );
exit;
}
}
Related Posts:
- How to restrict a page [without plugin]
- Hiding posts from non logged in users
- Restrict access to specific users
- How do we restrict a user to see a field in a post without registration,
- Hide posts of particular category for everyone except of particular user group or role
- How prevent direct access to PDF file
- How restrict video to be open on direct url hit
- Disable Page if user not logged in
- Learndash groups content protection with tags
- How can i restrict a page to certain user roles?
- Segregating content in a blog for 2 different readers
- Restrict directory listing to only logged in users
- Restrict content even to specific user
- I want to restrict a page for subscriber and contributor
- How to stop EU users from accessing my website?
- simple solution for restricting access to (some) uploads/downloads
- Does pre_get_posts affect REST API responses?
- Paid member plugin with some specific features [closed]
- How can I limit functionality in one version of a plugin?
- Shared Members between two different wordpress installations with different databases
- BuddyPress | Check if user is in current group [closed]
- Custom Roll/Custom Post Type – Can’t Select Categories
- WordPress roles – Protect administrator role
- Restrict certain posts from being sent to the feed subscribers
- Members area with externally-managed htaccess / htpasswd authentication?
- Restrict other Admins from using Editor in Admin Panel
- Restrict uploaded files into a custom folder to logged in users by htaccess: looking for Nginx – not only Apache – solution
- Redirect user to login before viewing custom post
- Is it possible to restrict viewing of category PAGE to logged in users only?
- Member plugin – register approval, restrict downloads, members only pages
- Removing all trace of member profiles
- Protect sequence of pages with same password for each of two groups of users
- How can I restrict image upload dimensions for non-admin WordPress users?
- Limit post display to post authors and create an exception for specific pages
- Facebook login for private group members
- How to show post content before read more tag (excerpt) for password protected posts?
- Add additional ‘description’ field for defined roles / role metadata?
- How do I log out users from a restricted page if they are already logged in on another device? [closed]
- Addin plugin custom post type to members plugin
- I restricted wordpress by logged users. It’s possible exclude a page?
- How to properly print a 404 error without redirecton? (i.e. keeping the current URL)
- How to allow registered users to submit the form only 5 times per day?
- Can I get an email notification when media is uploaded to the media library?
- Get a remote post ID via API given URL
- WordPress before save / update member
- Display count of new members registered today [closed]
- Downloadable content only for subscribers?
- Restrict the list of parent pages to only those which are created by current user
- How to restrict access to a single for users I’ve authorized? [closed]
- Is it possible to restrict access to specific pages in the admin area based on the page slug?
- How can I lock specific posts (cpt’s) from editing by anyone other than ADMINS
- How can I set a maximum allowed post size and number of posts submitted?
- How can I restrict a custom WordPress role access to only a specific plugin?
- Custom content before post content
- force login loophole
- Simple Math Quiz or Captcha to hide whois query form
- Creating a folder structure
- Add number of members to “Right Now” dashboard widget
- Prevent certain subscribers from seeing specific taxonomies (changes frequently)
- How do I “trash” a custom post type post while logged in as Admin
- Show/hide posts and categories based on user meta
- Uploading attachment (pdf) and prevent download for anonymous user
- can you help review CCCP (Conditional Cookie Content Post) and help to create a block?
- create a custom query for posts managed by Restrict Content Pro
- Limit users to specific uploads
- URL Restrictions? Need only people who are logged in AND have a specific role (or roles) to access all pages for a site
- Which membership plugin for a simple sign in? Personal areas for customers
- After reading 3 story by user ask for subscription popup
- Allow a page to be edited by a specific custom role
- How can I fetch user registration age
- How to use plugin’s shortcode in custom design? [closed]
- What permissions does a role need for the user to be assigned as the author of a post?
- Restrict access if logged out except for homepage
- How to show private pages based on a user’s role?
- Hide top admin panel for non admin and non editors
- WordPress Front-End user restricted taxonomies
- How to use url formatter with integer
- Custom User Role: Can Edit Own Page, Cannot Create New
- Restricted images only for logged user. (hidden url)
- Dynamic Home Page based on Log in status
- Using a page-template to restrict access based on IP (Frontend)
- I keep getting fake users registrations
- Set user role on registration so can upload file to own media library area
- Front end login and page restriction
- WordPress Shop and restricting products and categories for some users/groups
- Members only Passthrough
- Assign specific editor with custom user meta “A” to all authors with custom user meta “A” and exclude all other author access
- Restrict access to specific content
- Restrict download files from not generated Urls
- Basic File/Post restriction plugin
- How can visitors redirect wp-admin to the homepage?
- Step by Step Instructions for Making Media/Uploads Private to Only Logged-In Users
- Membership Plugin [closed]
- Browser Caching for Logged in Users
- Multisite Login Access Restrictions
- Restrict Image Sizes and Dimensions when Uploading via the WP Mobile App
- Hide custom posts from certain taxonomy in rest api
- Restrict page to members only does not work for page ID, slug or page title
- Content Restriction but allow public REST API
- How to restrict content on a subdomain to users that registers on main site?