Support » Plugin: Ultimate Member – User Profile, User Registration, Login & Membership Plugin » Restricting content outside of the_content(); + trouble with DearPDF

  • To whom it may concern:

    I’m presently working on a site with Ultimate Member installed, in addition to the DearPDF plugin as well (though DearPDF is not 100% related to every issue I’m experiencing at the moment).

    This said, I’m discovering that virtually all content outside of the_content(); is not being locked for users who are not logged in.

    Additionally, and perhaps more concerning, when Ultimate Member’s content restrictions are applied specifically to a standalone DearPDF post, absolutely nothing gets locked down. I can load the direct URL and the PDF embed and site footer will show up as if it were not locked down.

    I realize I can easily modify the .PHP of my theme with an if/else statement to check if a user is logged in or not, but that rather defeats the purpose – especially if I’m setting restrictions based on user role.

    I would like to know what suggestions the UM team has that would allow me to wrap the site’s more conventional content in the theme’s .PHP files (just FYI, I do know what I’m doing with them; the theme is partially bespoke).

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    Hello @cudak888

    Thank you for contacting our support.

    Ultimate member does not protect files but it only restricts posts/pages/taxonomies based on settings. If you have restricted a post and added shortcode inside the content area, UM can restrict access to that post but not the direct file url.

    If you are adding shortcode outside of content area, I suggest you wrap it inside conditional check.

    Regards,

    Thread Starter cudak888

    (@cudak888)

    Thank you for the reply.

    My issue is more granular than that. I’m seeing only elements wrapped in the_content() being hidden by Ultimate Member; otherwise, content written outside of the_content() in the page template is displaying to all users, regardless of the restrictions.

    As I mentioned, this is also creating issues on custom page types (e.g., the ones loaded by the DearPDF plugin), as those aren’t being hidden at all.

    May I ask what method would you recommend to wrap the external content with in the theme files? I’m aware of the general if/else tags that can be used with is_user_logged_in(), but if there’s something that can wrap it conditional to the UM settings for that page, I’d much rather do that, as I have some content that shouldn’t be accessible to certain users that would otherwise be visible if they can figure out the alternate URL.

    Plugin Support Aswin Giri

    (@aswingiri)

    Hello @cudak888

    You can try something like below:

    add_action('wp_footer',function(){
        if(function_exists('UM')){
            global $post;
            if( ! UM()->access()->is_restricted($post->ID) ){
                echo 'return content';
            }else{
            echo 'Show restriction message or do nothing';
            }
        }
    });

    On the above code exmaple I am just adding conditional check with wp_footer hook but you don’t need to do that. You can just make changes to code as per your requirement.

    Thread Starter cudak888

    (@cudak888)

    Thank you! This worked perfectly. I also went a step further and added the following on a few pages so I could run a few if-elseif-else statements by user role:

    if( ! UM()->access()->is_restricted($post->ID) && UM()->user()->get_role() !== 'um_MYUSERROLE' )

    Thank you once again.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.