Membership Plugin

WordPress Membership Plugin

  • Home
  • Documentation
  • Addons
  • Support
    • Quick Setup
    • Documentation
    • Premium Addon Support
    • Paid Support
    • Support Forum
    • Support Forum Search
    • Forum Login
    • Forum Registration
  • Contact

[Resolved] Allow bypassing protection?

Simple Membership Plugin › Forums › Simple Membership Plugin › Allow bypassing protection?

  • This topic has 7 replies, 3 voices, and was last updated 7 years, 2 months ago by Uwe Trenkner.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • April 28, 2019 at 2:44 pm #18022
    Uwe Trenkner
    Participant

    I need to allow a server in our network unprotected access to WP posts otherwise protected by Simple Membership (via wget).

    Is there a configuration/hook that would make it possible to allow access for requests with a certain secret GET-Parameter? E.g. could I somehow allow a request like this full access to post #123: https://www.mydomain.com/?p=123&allow=9Uxc5bNxJbjFHB5K6EfR

    Or else for requests from a certain IP address?

    April 29, 2019 at 1:31 am #18029
    mbrsolution
    Moderator

    Hi, are you referring to something like this

    https://simple-membership-plugin.com/simple-membership-api-querying-member-account-using-http-post-request/

    Regards

    April 29, 2019 at 7:12 am #18034
    Uwe Trenkner
    Participant

    Thank you for the link. But the API is only about members. I am looking for a possibility to allow a server in our network access to protected content. The server could be identified by IP address and or some GET-Parameter (similar to how you use the API key).

    I know how I can achieve this by adding a single line of code to the validation function of SWMP. But I would like to not go down this route as I would have to re-do this after every upgrade of SWPM. That’s why I was looking for an “official” way which works without changing the source code.

    April 29, 2019 at 9:20 am #18036
    mbrsolution
    Moderator

    Hi, unfortunately there is no option in the plugin at the moment to achieve what you are trying to do.

    I know how I can achieve this by adding a single line of code to the validation function of SWMP. But I would like to not go down this route as I would have to re-do this after every upgrade of SWPM. That’s why I was looking for an “official” way which works without changing the source code.

    You might like to try your solution. If you don’t mind, you might like to share your solution here for others to use. The developers will also check your code and decide if they can use it or not.

    Kind regards

    May 2, 2019 at 1:54 pm #18096
    Uwe Trenkner
    Participant

    Sure, I gladly share my hack – maybe it helps others, too:

    I add in /simple-membership/classes/class.swpm-access-control.php between line 19 and 20

    
    if (isset($_GET['swpm-bypass']) and $_GET['swpm-bypass']=='9Uxc5bNxJbjFHB5K6EfR'){
    	return true;
    }
    

    This allows full access to the post if I add the GET-variable swpm-bypass=9Uxc5bNxJbjFHB5K6EfR to the URL, e.g. https://www.mydomain.com/my-great-post-title/?swpm-bypass=9Uxc5bNxJbjFHB5K6EfR

    Note, only use this on HTTPS websites – otherwise the string will go unencrypted over the internet…

    And, of course, don’t use 9Uxc5bNxJbjFHB5K6EfR as your “bypass-word”. It’s just an example.

    May 2, 2019 at 9:52 pm #18100
    mbrsolution
    Moderator

    Thank you for sharing 🙂 your solution.

    Enjoy the plugin.

    May 4, 2019 at 8:48 am #18113
    admin
    Keymaster

    Thank you. I will be happy to add an action or filter hook somewhere that will allow you to override this from your custom code (without having to modify the core plugin’s code). If you make the proposed solution/suggestion for the hook, I will look into add it to the code.

    May 22, 2019 at 10:59 am #18296
    Uwe Trenkner
    Participant

    @admin Thank you for the offer – I have not yet looked into how this would look like with a hook.

    But I wanted to post a warning and fix here, for everyone: I noticed that in certain situations WordPress redirects pages with the whole QUERY-string. If that URL is exposed to e.g. a user, he gets to know the secret bypass string.

    I therefore trigger the bypass now via an HTTP header, which is never returned by WordPress. And in order to make the code portable, I decided to use a hash of WP’s auth salt. This way the secret bypass string is unique to every WP installation. In class.swpm-access-control.php, I now start the can_i_read_post() function like this:

        public function can_i_read_post($post){
            if ( isset( $_SERVER['HTTP_X_SWPM_BYPASS'] ) ){
                    $bypass_key = hash( 'sha256', wp_salt('auth') );
                    if ( $_SERVER['HTTP_X_SWPM_BYPASS'] == $bypass_key ){
                            return true;
                    }
            }
    ...
    
  • Author
    Posts
Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.
Log In

Please read this message before using our plugin.

Search

Featured Addons and Extensions

  • Membership Form Builder Addon
  • Member Directory Listing Addon
  • WooCommerce Payment Integration
  • Member Data Exporter Addon

Documentation

  • Documentation Index Page

Copyright © 2026 | Simple Membership Plugin | Privacy Policy