Not sure about the best practices, but I have a few custom login-sensitive pages which simply display a message if user is not logged and is trying to view the page directly:
$logged_in = is_user_logged_in();
if($logged_in) {
?>
<article id="post">
<?php the_content(); ?>
</article>
<?php
} else {
_e('You are not logged in. Please ', 'abc');
echo '<a href="' . site_url( 'login' ) . '">'. __('log in','abc') .'</a> ' . __('or','abc') . ' ';
echo '<a href="' . site_url( 'register' ) . '">'. __('register','abc') .'</a>.';
}
Note: both the login
and register
pages are custom pages as well.
Related Posts:
- wp_nonce_field displaying twice
- How to add conent (text) to Add New pages form of admin in WordPress
- Create pages for authors
- How to store username and password to API in wordpress option DB?
- In Which Contexts are Plugins Responsible for Data Validation/Sanitization?
- PHP error with shortcode handler from a class
- Add self-closing shortcode button to TinyMCE in WP 4.6
- Change the_title() of a page dynamically
- Optimize shortcode callbacks
- Nonces can be reused multiple times? Bug / Security issue?
- WordPress and PHP Sessions – Security and Performance
- Are shortcodes case-sensitive?
- Allowing for multiple template views on the Gallery Settings page when using the Visual Editor
- How to edit the properties of a page programmatically?
- Log in from one wordpress website to another wordpress website
- How to make WordPress use non-greedy shortcode parsing?
- How do I make specific plugin functionality apply to different sites in a network?
- Escaping built-in WP function return strings
- WP Cron doesn’t save or in post body
- Filter on the_content ignores shortcodes
- Pages 404 in wordpress
- stray elements
- Pass javascript result to shortcode executer function
- How to create a dynamic page based on form data with a plugin?
- Is it possible for a plugin to register a page template file?
- Calling a function from functions.php in custom page/ blog post
- How do I approach removing menu items on the fly based on settings in my plugin?
- Set a specific page as 404 – not found via my own plugin
- Plugin development: is adding empty index.php files necessary?
- add_shortcode is not working [duplicate]
- How can I render shortcode so that its not cached by Caching plugins?
- Create a Page via plugin
- Processing shortcodes in groups (separated by line breaks)?
- Why do I need to check if wp_nonce_field() exists before using it
- Is there any way to check for user login and send him to login?
- WordPress security issue to output data from user input from theme option form
- Storing product price data in the database
- What is the best way to embed an JS App in a WordPress Page?
- Auto gallery from folder contents
- add_shortcode() not working inside of function
- Securing/Escaping Output of file content – reading via fread() in PHP
- Asynchronously render shortcodes in TinyMCE visual editor
- Custom login doesn’t work properly
- Is using custom table to suit business needs instead of transients a big hit to page load speed?
- best way to make a WordPresss multisite that is secure but at the same time supporting my plugin development efforts
- Run Shortcode of post’s custom field in functions.php / Plugin
- Video Security just like facebook [closed]
- Hide shortcodes “code” when using the “editor” the same as wordpress do with “gallery”
- Is disabling test_form in wp_handle_upload a security concern?
- How to connect my wordpress plugin to a remote database securely?
- Wrap text around shortcode
- How to handle shortcodes through plugin
- Using a custom shortcode from within the template of a shortcode plugin
- When echoing my own shortcode, it keeps adding a 1 at the end of my blogpost
- How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?
- add_submenu_page hooked function must explicitly check user capabilities – why?
- Automating the process of shortcode generation in a plugin – how is it done?
- Create Widget or Enable Shortcodes in Sidebar
- shortcode executed in the page editor
- Shortcode not appearing when used as post content in wp_insert_post() or possibly, shortcode not being registered at all
- How to make my shortcode load scripts and styles, from within the plugin?
- Shortcode conflicts
- How to create ShortCode
- Is it possible to use WP-CLI in a plugin (or theme)?
- Secruity Questions on a timer
- How to output functions from plugin inside theme
- add_filter img_caption_shortcode not implemented
- shortcode tags not working in do_shortcode
- Using HTML links within translatable string
- How to insert HTML/CSS/JS into my iframe plugin?
- How can I save a password securely as a settings field
- Form submission to another page returning 404 error [duplicate]
- Using password protection to load different page elements?
- Set page to draft on plugin deactivation
- Font size of HTML content
- Cannot output plugin twice with shortcode
- Load specific page when a custom URL is hit
- WPGut – Updating failed and shortcode?
- How to write a custom shortcode name book?
- Plugin frontend page design irrespective of the theme used
- How can I pass WP_Query results to a plugin?
- How can we stop showing short code in create or edit post section
- Custom non-template page on front end fails to render
- Pass javascript result to shortcode executer function
- Shortcode from a plugin not working
- What is more secure checking capabilities of user or checking role of user in WordPress plugin development
- How do I control the list of Pages an author can see?
- Is there a way to tell if a shorcode’s handler is being run before or after the content formatting filter?
- auto create only 1 wp page in activate custom plugin
- Cannot echo a JS variable to a jQuery plugin coming from wp_localize_script
- add short code not working
- Loop output for custom plugin [solution found]
- How to Pass ID through Short Code
- Shortcode attribute “title” doesn’t appear in $atts array
- How do I use (or mimic) document.getElementById() on a page loaded from WordPress database?
- WordPress simple ‘Hello World’ plugin – problems
- Shortcode rendered in preview, but empty in post
- How to display .ptm file in my WP site without JAVA
- Developing an IP lookup function using an API
- Generating Multiple Divi Pages from Database