WordPress.org

Ready to get started?Download WordPress

Forums

links for registered users only (9 posts)

  1. darkppl
    Member
    Posted 5 years ago #

    I RUN A WORDPRESS BLOG AND I POST Links to different stuff like open source programs, freewares etc.... i actually want that the visitors (unregistered or those who didnt login) should be able to see my whole post but not the links,,, and in the links space it should be written "register or sign in to view links" only registered and logged in users should be able to see the download links....is it possible?

  2. esmi
    Forum Moderator
    Posted 5 years ago #

    Don't know of any plugin that would do this across a whole blog.

  3. darkppl
    Member
    Posted 5 years ago #

    what about doing it for each post individually?

  4. dor
    Member
    Posted 5 years ago #

    My plugin hopefully can do this ( http://wordpress.org/extend/plugins/replace/ ). It searches for patterns and replaces it with specified string...

    I've just committed a possibility to specify different replaces for authenticated and non-authenticated users... (New in version 0.1.3)

    Did some tests... Warning, it is "beta-feature" but seems to work. I hate this but... "It works for me".

    I'll be back tomorrow and i'll do some more tests.

    This will work.

    Probably you need another possibility: to specify "some posts" (by post IDs or in "Edit post" page) to be processed etc --- this is "not available yet"; so you'll need to fine-grain your regular expressions for links (by adding class="forregistered" or like that).

  5. dor
    Member
    Posted 5 years ago #

    SORRY

    Didn't add re.place-restrs.php yesterday. Corrected.

    Anyway, it is working but still is being tested.

  6. darkppl
    Member
    Posted 5 years ago #

    well dor can u tell me in detail for can i hide links in posts individually?

  7. dor
    Member
    Posted 5 years ago #

    Well, i plan to add a "restriction" to replace on certain post IDs (entered as comma-separated list)... so now you can do this on _links_ individually...

    For example, write

    <a href="..." class="forregistered">Link for registered</a>

    if you wish this link to be accessible by registered users only.

    Then add re.place entry let's say like this:

    Search pattern:

    (<a [^>]* class="forregistered"[^>]*>([^<]*)<\/a>)

    Replace pattern:

    \1

    Restriction: for authenticated users

    Otherwise use:

    \2

    This will replace links with link text for guests; so <a href="...">Test it</a> will become Test it.

    In "Otherwise" field you can write smth like this:

    <span class="forguests" title="For registered users only">\2</span>

    ... or:

    <a href="/your/registration/url?redirect_to=\2">\2</a>

    In above --- you can change search pattern to have an original link URL as an \<digit> for reference.

    Also, a "tag" for links to be replaced must not be class="smth", you can use other "tags".

    Well, i know, this a bit ugly if you need to do this on some posts basic, with no manual intervention like class="smth" or the like... Hope i'll add this possibility later.

    Now i'm figuring out how to change GUI to make it convenient if filled with this and possible other features.

  8. darkppl
    Member
    Posted 5 years ago #

    well thats hefty work... aint there anything simple to do that?

  9. dor
    Member
    Posted 5 years ago #

    :-)

    You're right.

    Yes, re.place hasn't been created for this specific task.

    About anything simple... It seems that nobody knows so far :-(

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags