WordPress.org

Support

Support » Plugins and Hacks » Protect Old Posts

Protect Old Posts

  • Hi, I’ve been trying to modify the Protect Old Posts plugin to protect all but the most recent 170 posts or so, as opposed to one.

    I’ve tried doing this a number of ways, but I’m definitely not a php/sql guru. All that I’ve been able to do so far is to protect the 170 oldest, which repeats and eventually protects all of them.

    What I’m looking for is a way to do this by either date (preferable) or ID. I know there should be a way to do this, either by limiting a range or something along those lines, but I don’t have the knowledge quite yet to figure it out.

    Any input would be appreciated.

    Thanks,
    Sara
    bleary-eyed.net

Viewing 8 replies - 1 through 8 (of 8 total)
  • Not familiar with this “Protect Old Posts” plugin. Does it stop other authors from editing it or does it close comments or what?

    If you’re looking to just close the comments on old posts, you can either manually do it via a database query or via a plugin to automatically lock comments after X days.

    I forget the name of the plugin that works really well for doing the above though. 🙁

    It password protects old posts with a default password set in the plugin. I’d still like to be able to give people this password who I know personally, so it would be the ideal setup.

    Yup, I’m bringing up an old unresolved issue. I have still been unable to modify the plugin to protect all posts beyond a certain date or number. Any advice?

    $default_password = 'changeme';

    function mm_something_changed($something) { // This is extremely crude
    global $wpdb, $tableposts, $default_password;
    $count = $wpdb->get_var("SELECT COUNT(*) FROM $tableposts WHERE post_status = 'publish'");
    $one = $count - 1;
    $wpdb->query("UPDATE $tableposts SET post_password = '$default_password' WHERE post_status = 'publish' AND post_password = '' ORDER BY post_date_gmt ASC LIMIT $one");
    return $something;
    }

    I tried by editing the ASC limit among a million other things, but it’s been quite a few months since I’ve tried messing with it and I’d still like to do it. Any suggestions?

    i already installed this plugin into my blog. i didn’t realize that this plugin will automatically insert password to ALL my entries.

    and now, i have to manually delete all the password that has been inserted in my entries one-by-one. it would tak e a veryyy long time.

    do u have any ideas how i can automatically delete the inserted password? instead of doing it one-by-one?

    i deleted this plugin from wp-content/plugin, but still no change.

    your help is very much appreciated. TQ.

    “do u have any ideas how i can automatically delete the inserted password? instead of doing it one-by-one?”

    If you have direct access to your database outside of WP:

    update wp_posts set post_password = '';

    Assuming your tablename is wp_posts. By direct access, I mean something like phpmyadmin or even “mysql” client over SSH for instance.

    pizdin_dim,

    can u explain more…
    i really don understand and still blur…
    i’m in programming background..
    so hope u can teach me how to do it, step by step.

    TQ very much for your kindness.

    —-

    and 1 more thing, how to access to my database? thru cpanel? (i can login to my cpanel)

    I don’t use cpanel, so I can’t comment on that. Basically, you’ll need direct access to your database with some tool like “phpmyadmin” where you can run queries. An alternative would be a “SSH” client like “putty” which would enable you to connect to the server and run the “mysql” client. In both cases, once you have connected to your database, you’ll need to run the query that I posted above.

    Contact your host and ask them about what options they have.

    Or you could just take the plugin and reverse it. Take the area where they insert your new password (‘CHANGEME’) and leave it blank, and then take the blank area where it changes all non-protected posts and put in the password you used.

    That will change all posts with that password into no password. Then upload and reactivate the plugin. For instance:

    $default_password = ”;

    function mm_something_changed($something) { // This is extremely crude
    global $wpdb, $tableposts, $default_password;
    $count = $wpdb->get_var(“SELECT COUNT(*) FROM $tableposts WHERE post_status = ‘publish'”);
    $one = $count – 1;
    $wpdb->query(“UPDATE $tableposts SET post_password = ‘$default_password’ WHERE post_status = ‘publish’ AND post_password = ‘*************THE PASSWORD YOU USED********’ ORDER BY post_date_gmt ASC LIMIT $one”);
    return $something;

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Protect Old Posts’ is closed to new replies.
Skip to toolbar