How to find hacked Wordpress pages containing spam - wordpress

No sooner is my website fully functional that it gets hacked. If you do a Google search with the link below, the results show spam keywords in the pages throughout such as "casino", "blackjack", "slot", "deposit", etc. But if I look through the pages, I don't see any of the spam.
Here is the Google search result:
https://www.google.ca/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=site%3Arichardrosenman.com%20richard%20rosenman
I am not very advanced with Wordpress or PHP and I have tried searching. Can anyone help me figure out where it was hacked and how I can clean and protect it?

Since 'social.png' is included and there are spam keywords you probably are experiencing a CryptoPHP hack. There's much to find about it (in combination with Wordpress) and, fortunately, how to clear it.

Same happend with one of my client, he has only 15 posts in backend but google shows some wierd keywords and post which is crawed. To check this kind of posts/pages you have to look in the database. wp_posts table holds all the custom post types, pages etc, and display only the post that has publish status in post_status section.
To retrive all the published pages or post use the following query.
// will display all posts/pages etc.
SELECT * FROM `wp_posts` WHERE `post_status` = "publish"
// Display only Pages
SELECT * FROM `wp_posts` WHERE `post_status` = "publish" and `post_type` = "page"
// Display only posts
SELECT * FROM `wp_posts` WHERE `post_status` = "publish" and `post_type` = "post"
Now you know how to filter data, every record from this filtered data has a column post_author that holds the ID of the user that published that post/page.
Go to the wp_users table and check your user_login name and get the ID of your administrator account. And again filter the run a query in wp_posts table to filter the anonymous users data.
// Make sure you have only one administrator, replace 1 with your user id
SELECT * FROM `wp_posts` WHERE `post_author` not in (1)
// If you have multiple administrator then use the following, replace 1,5,6 with admin ID's
SELECT * FROM `wp_posts` WHERE `post_author` not in (1,5,6)
And final step is to delete that.
Important: Before Apply this action make sure to take backup first, so just in case you can retrive that data later.
Hope this help you.

Related

How do I delete orders from a cloned WooCommerce site?

I have used NS Cloner to clone site within WooCommerce. This has worked extremely well but the existing orders have been duplicated in the cloned site; I obviously would like remove all of these. In total there are 17,000 or more that I need to remove so doing this in the Admin area isn't an option as it does in 20 batches. There isn't an option to do a bulk delete. I have a suspicion I make have to do this at a mysql level. There is a plugin out there (WC Delete All Orders) but the reviews are less than favourable.
Could some one point me in the right direction please?
You can use this plugin in order to delete in bulk
https://wordpress.org/plugins/woocommerce-store-toolkit
So I used SQL query for this one:
UPDATE wp_posts SET post_status = 'trash' WHERE post_type = 'shop_order';
from this link - how to delete completed orders in woocommerce using a my sql query

How can I easily access all post titles for editing from WooCommerce in phpMyAdmin?

I have imported a ton of products, but I need to go through and edit every title for conciseness. I went into the database in phpMyAdmin, but can't seem to locate the titles.
I looked under wp_posts > indexes, but can't quite figure it out.
I want to basically bring up all titles in a big list in phpmyadmin and go through editing them one by one.
I'm not familiar with WooCommerce but from a looking at their documentation, products are stored as product post type. This means you can run an SQL query in phpMyAdmin to only show posts matching that post type.
SELECT post_title FROM wp_posts WHERE post_type = 'product'
The above query will return all posts matching the product post type but only return the post_title (a.k.a the product title).
If you want to show all fields run the following.
SELECT * FROM wp_posts WHERE post_type = 'product'
Back up your database before doing anything, just incase!

is it possible after customer place a order and then admin assign a specific order to a vendor in wc marketplace plugin

Is it possible after customer place a order and then admin assign a
specific order to a vendor in wc marketplace plugin
WCMarketplace keeps vendor orders as dc_commission - post type.
I have researched when you creating order with vendor product. WCmarketplace creates dc_commision post
in the database, you could see all this post with such SQL query
SELECT * FROM wp_posts where post_type = 'dc_commission'
Then, also, wcmarketplace creates meta keys for this field.
You could use such SQL query for seeing this
SELECT * FROM wp_postmeta where post_id = 14;
The meta keys are
_commission_vendor
_commission_product
_shipping
_tax
_commission_order_id
_paid_status
_commission_amount
There is no standard functionality for your purpose.
You could add this functionality by this steps
You could create a custom meta box for admin order page.
WooCommerce : Add custom Metabox to admin order page
You could write code for metabox. For creating new post with post type 'dc_commision' and then add post meta _commission_vendor
_commission_product
_shipping
_tax
_commission_order_id
_paid_status
_commission_amount
Where commission_order_id = is current page order id. Other parameters you could write by researching then in other dc_commisions post type analogically.
3. You could add functionality to your meta box for choosing a vendor and set _commission_vendor id. This id is in wp_users_meta table with meta key vendor_term_id. You could get vendor_term_id and then set to _commission_vendor.

Wordpress Woocommerce change all products to out of stock

Hello i have a online shop using Wordpress and Woocommerce but i have the following problem. I need to change all of my 2000 products to be out of stock, i haven't selected any quantity i only need to change the status. I started doing it by hand but it will take quite a while to mark all the items. After browsing the net i saw that this can be done relatively easy in phpmyadmin, the status is stored in wp_postmeta, i myself tried fiddling with the queries of phpmyadmin but to no avail . Can someone help me with building the query that i need to use ? I use WP 4.1.1
ok bro write this query in your db
Update wp_postmeta Set meta_value = 'outofstock' Where meta_value = 'instock' And meta_key = '_stock_status'
I restricted update query more by using And meta_key = '_stock_status'
Hope this will help you ... don't worry query is completely right but you must take a DB backup

Wordpress - Sort posts depending on value of Custom Field and alphabetically

My client has a website listing different sailing services. These services have different levels of subscription:
Free
Premium
Full
In the back end, I have set up some Custom Fields using Advanced Custom Fields (which work perfectly as normal WP custom fields). The Custom Field for that service is called "subscription_level" and it's a dropdown list with the options mentioned above.
What I'm trying to achieve is to display the posts in the order of the level of subscription and alphabetically. So first, you'd have all the "Full" services sorted by title, then the "Premium" and then the "Free" ones.
Like:
---- Full ---
Full Service A
Full Service B
Full Service C
---- Premium ---
Premium Service A
Premium Service B
Premium Service C
---- Free ---
Free Service A
Free Service B
Free Service C
Ideally this should also have pagination, but if that's not possible, it's not the end of the world.
I have tried several custom select queries by looking at the Codex instructions, without luck. My problem is I need two ways of "orderby"? One that divides the posts according to the meta_value of a my custom field "subscription_level" and at the same time one that orders each level of subscription by title... and I just can't seem to find a way of achieving this.
Any ideas pointing me in the right direction would be awesome!
Thanks in advance
Hope I understand the problem:
You have a post_type "services" (or this actually are your standard posts)
each of these services has a subscription level like "free", "premium", or "full" stored in a custom field
So the first thing to do is categorizing the posts into these levels.
Afterwards inside these levels the posts should be ordered according to their title ( or other).
I am not sure if it is easy to achieve this with one custom SQL-query. It suppose it would be something like this:
SELECT * FROM wp_posts,wp_postmeta.meta_value INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id WHERE wp_posts.post_status='publish' AND wp_postmeta.meta_key = "service" ORDER BY wp_postmeta.meta_value, wp_posts.post_title, ASC
But if this gets to complicated you can chose another way to achieve this aim. Collect the IDs of all "Full service" posts, the IDs of all "Premium service" posts and the IDs of all "Free service" posts, f.e.
SELECT wp_posts.post_ID FROM wp_posts INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id WHERE wp_postmeta.meta_key = "service" and wp_postmeta.meta_value="premium"
(do this for each kind of service)
Afterwards you run WP_QUERY with the 'posts_in'-array or another custom SQL-Query where you order the collected posts by title or a new value.
Depending on what kind of paging you want to use, there is a blog post about how you can integrate custom paging in a simple way yourself:
http://www.blackbam.at/blackbams-blog/2011/07/18/implementing-a-simple-and-flexible-paging-algorithm-using-php/
Hope this helps.

Resources