Good afternoon, tell me how to prohibit an unregistered user from seeing a page or a rubric, let's say there is a rubric that is displayed if(is_user_logged_in()){} , garbage somehow turns out if I am logged in and am in the hidden rubric and then I exit, it turns out that the path to the address bar remains and if I am not registered I can simply type in my hands http: // website / hidden-heading and calmly follow the link. The meaning of the fact that I hid the output of headings in the menu or somewhere else when you can just type in the url and get into the heading.

    2 answers 2

    There are many different options to restrict access to content.

    You can use the function in the theme template .

    You can shortcode.

    add_shortcode( 'members_only', 'members_only_shortcode' ); function members_only_shortcode( $atts, $content = null ) { if ( is_user_logged_in() && !empty( $content ) && !is_feed() ) { return $content; } return 'Для просмотра скрытого содержимого, вы должны авторизоваться.'; }

    In the post insert shorkod:

    [members_only] Текст только для авторизованных. [/members_only]

    There are also a bunch of ready-made plug-ins for almost all occasions :).

    Looks like this one will do.

      The question is what and where displayed. It is necessary to put if(is_user_logged_in()){} inside the template that displays the contents of this category.

      In general, the site is not worth checking is_user_logged_in() . The function works fine, it was checked more than once.