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 handle shortcodes through plugin
- Is it necessary to do validation again when retrieving data from database?
- 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
- Checking a WordPress for OWASP top 10 vulnerabilities [closed]
- How do I have now a duplicated user entry if this is not allowed (and I cannot replicate it)?
- Add Password Generator on password protected page
- add_submenu_page hooked function must explicitly check user capabilities – why?
- Are there any security risks when submitting data-attribute data through AJAX?
- ECHO Executing 4 Times In Head
- Automating the process of shortcode generation in a plugin – how is it done?
- WordPress pages are not published due to External database connection with WPDB class
- Create Widget or Enable Shortcodes in Sidebar
- Create page (not the post type) dynamically
- Why would you use esc_attr() on internal functions?
- 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
- Multiple array for post_content on plugin activation
- How to make my shortcode load scripts and styles, from within the plugin?
- How to display the categories on page using shortcode?
- Shortcode conflicts
- How to create ShortCode
- Is it possible to use WP-CLI in a plugin (or theme)?
- How to display the specific post content by using POST ID
- 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 list all images used on a specific page?
- Create fixed static pages
- How to insert HTML/CSS/JS into my iframe plugin?
- How can I save a password securely as a settings field
- Including template in shortcodes
- Form submission to another page returning 404 error [duplicate]
- Passing values between enclosing and enclosed shortcodes
- post content and shortcode content displaying out of order
- 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
- Paragraph Tags removed when contents are only a shortcode
- How to create archive page to add in menu
- Load specific page when a custom URL is hit
- How to call a function from a shortcode function in an oop plugin
- WPGut – Updating failed and shortcode?
- HTML Elements in my WP Plugin being generated in JS. Security and Translated Text Question about this method being used
- How to write a custom shortcode name book?
- By adding “?login – failed” code unable to access my dashboard
- Plugin frontend page design irrespective of the theme used
- How can I pass WP_Query results to a plugin?
- How to store sensitive user data (passwords)
- How can we stop showing short code in create or edit post section
- Custom non-template page on front end fails to render
- Shortcode content is not showing. Only the [shortcode-tag] is showing
- How do I make secure API calls from my WordPress plugin?
- esc_attr() on hard coded string
- how to add security questions on wp-registration page and validate it
- Including content into an add_shortcode() function
- Pass javascript result to shortcode executer function
- Some data has already been output, can’t send PDF file – fpdf issue in WordPress
- How do I make two shortcode use the same id and increment it when I use them multiple times?
- Shortcode from a plugin not working
- Experts opinions needed: How (in)secure is this approach?
- Which filter to use to pre-parse form elements, which are generated by plugin’s shortcode?
- Caption Shortcode: what filter to change the image size?
- 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
- Do a summary based on sections in a post
- Children Shortcodes?
- Wrapping shortcodes in another shortcode
- Identifying a Page Containing Shortcode at `init`
- Cannot echo a JS variable to a jQuery plugin coming from wp_localize_script
- How to show custom taxonomy child posts through shortcode in WordPress
- Multi-part form and wp_redirect()
- Data Validation, dynamically generated fields (select for example)
- add short code not working
- Loop output for custom plugin [solution found]
- Correct usage of scripts with shortcodes
- 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?
- Developing a wordpress.com shortcode [closed]
- WordPress simple ‘Hello World’ plugin – problems
- Using a Page Template Not in Theme
- Shortcode rendered in preview, but empty in post
- How to display .ptm file in my WP site without JAVA
- Leveraging Core Functionality in Icon Upload Plugin [closed]
- esc_url, esc_url_raw or sanitize_url?
- Developing an IP lookup function using an API
- Generating Multiple Divi Pages from Database
- Problem with Owl Carousel, infinite loop [closed]
- Shortcode to return data instead of outputting HTML?
- Using a shortcode to get User Emails by role as specified in the shortcode, need help to allow for multiple roles
- Is there a way to decide from init whether we are on a certain backend page?