WordPress.org

Ready to get started?Download WordPress

Forums

WP-Members
need to securiy attachment rather than the_content; what code do I change? (7 posts)

  1. bartland73
    Member
    Posted 1 year ago #

    I'm trying to allow the post content to remain visible, but require a login to download the attachment to a page. I see that line 146 of wp-members.php puts security on the_content:
    add_filter( 'the_content', 'wpmem_securify', 1, 1 ); // securifies the_content

    With what do I replace "the_content" in that line to securify the attachment instead?

    thanks,
    Bart

    https://wordpress.org/plugins/wp-members/

  2. Chad Butler
    Member
    Plugin Author

    Posted 1 year ago #

    Don't take this the wrong way, but your question is the equivalent of, "How do I change my Jet Ski to be a Snowmobile? What do I change on the throttle to make it run on snow?"

    The line of code you want to change is a specific hook in WordPress. It passes the_content through the function wpmem_securify.

    That function is designed specifically to filter the value of the_content and return results based on various criteria. You can't change what wpmem_securify is hooked to an expect a valid result.

    If what you want to do is hide a link from non-logged in users, you can do that with the plugin's status shortcode (i.e. [wp-members status="in"]some text here[/wp-members] ). However, that does not prevent the link from being accessed if it is known. For that you need to prevent access to the file with something like .htaccess.

  3. bartland73
    Member
    Posted 1 year ago #

    That makes sense...and I think the shortcode you mentioned will help me with what I need. (I didn't see that anywhere in the documentation) Thanks so much for the help!

  4. bartland73
    Member
    Posted 1 year ago #

    Actually, what is the equivalent php code for that shortcode? If it's in the documentation, can you guide me to where I can find it? (I need to place it in a post template file)

    Thanks again. :-)

  5. bartland73
    Member
    Posted 1 year ago #

    Sorry for the multiple replies...I just tried the shortcode, but it simply hides the content without prompting the user for a login, which doesn't fit what is needed. Do you know of any possible solutions to require a login for something other than the main page text?

  6. Chad Butler
    Member
    Plugin Author

    Posted 1 year ago #

    If you want to prompt for login, add the login page shortcode nested in a status="out" shortcode. So altogether for this page you have:

    [wp-members status="in"]some text here[/wp-members]
    [wp-members status="out"]
    [wp-members page="login"]
    [/wp-members]

  7. bartland73
    Member
    Posted 1 year ago #

    Thanks! How would I utilize that as a php function (rather than a shortcode), to conditionally append code/text to the_content in a php file?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic