We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Bulk expire all posts by user

How Do I?

The Conman's avatar
The Conman
4 posts
9 years ago
The Conman's avatar The Conman

Is there an easy way to bulk expire all posts by a user using a tool such as ‘mysql’ ? We have nearly 2000 news postings that we want to close down but don’t want to have to manually edit 2000 items to set the expiration date.

Thanks in advance.

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
9 years ago
Ingmar Greil's avatar Ingmar Greil

Sure, you can run an SQL query on your database (be sure to make a backup first). I’m thinking of something like this:

UPDATE exp_channel_titles AS t SET t.status = 'closed' 
WHERE t.status = 'open' AND t.author_id = "99"

You’ll need to adjust the author_id, of course.

ETA: Changing the expiration date can be done in a similar manner, using expiration_date.

       
The Conman's avatar
The Conman
4 posts
9 years ago
The Conman's avatar The Conman
Sure, you can run an SQL query on your database (be sure to make a backup first). I’m thinking of something like this:
UPDATE exp_channel_titles AS t SET t.status = 'closed' 
WHERE t.status = 'open' AND t.author_id = "99"
You’ll need to adjust the author_id, of course. ETA: Changing the expiration date that can be done in a similar manner, using `expiration_date`.

What database would I work with? I would guess exp_weblog_data.MYD? Is there a sql query I could run to see what posts would be affected? Would t.author.id equal the friendly username like “The Conman” or would I need something else? I guess if something doesn’t work correctly I could always change the t.status = ‘closed’ to ‘open’ should it not work right.

By no means do I have any experience here and do not want to hose the database and/or site! So, the more steps the better for me.

Thanks again.

       
The Conman's avatar
The Conman
4 posts
9 years ago
The Conman's avatar The Conman

In fact - would I use the ‘mysql’ tool on the Linux box? Again, the more steps the better in this case for me. Also, I did look thru the documentation and forums here trying to find a gem that would have led me to a solution. Was anything like what I’m asking documented anywhere?

Again, thank you in advance.

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
9 years ago
Ingmar Greil's avatar Ingmar Greil
What database would I work with? I would guess exp_weblog_data.MYD?

There is only one EE database, and you should never touch your db on a file system level under ordinary circumstances. exp_weblog_data is a table of that db, but not the one to use: my example used exp_channel_titles. (You seem to be on a very old version of EE, by he way. weblogs were renamed to channels in 2009, if memory serves.)

Would t.author.id equal the friendly username like “The Conman” or would I need something else?

The user_id would be numeric, like the ‘99’ in my example.

In fact - would I use the ‘mysql’ tool on the Linux box?

No. If you don’t want to use an external tool like phpMyAdmin, you can use the query form of the built-in SQL Manager. That said, you really should have an idea of what you are doing. In your case it might be a good idea to get help from somebody familiar with SQL.

       
The Conman's avatar
The Conman
4 posts
9 years ago
The Conman's avatar The Conman

Worked with one of our SQL guys internally and was able to get this taken care of. I just wanted to say thanks for the help getting this started.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.