Delete users by date wordpress Mysql

spam users which was registered. I used following Mysql commands for removing he wordpress users. query for Delete users by date wordpress Mysql

 

Some days before I enabled the my site registration as subscribers. In last seven days there are four thousand subscribers has been registered on my site. After reviewing the users and there server request logs I got to know about that was spam users which was registered to my site. WordPress is always easy target for spammers and hackers. I tried to use some code for remove the wordpress users but then later I used following Mysql commands for removing he wordpress users.

Delete users by date wordpress Mysql

 

When you create or register the user in wordpress that time some tables are filled by wordpress. Some entries will insert into wp_usermeta table and wp_users table. If you want to delete the bulk users then you need to delete user entries from wp_usermeta table first. You can use following SQL command for deleting the user meta entries from wp_usermeta table.


DELETE wp_usermeta FROM wp_usermeta, wp_users WHERE wp_users.user_registered > '2013-11' AND wp_users.ID = wp_usermeta.user_id;

After deleting the user meta entries from table then remove users from wp_users table using following command


DELETE FROM `wp_users` WHERE `user_registered` > '2013-11';

Note: Before deleting the users from wordpress database, take the Database backup. Take the worpdress backup and restore on local box. Make sure your DB backup file is perfect.

Do not delete users from wp_users at the first. First delete user meta from wp_usermeta then execute the next command.

 

Remove category slug wordpress from URL

Wp Developers are always looking for remove the category or blog slug from wordpress URL.  We can very easily remove the blog word from wordpress blog URL. Many clients want to remove the category word from URL. There are some nice wordpress plugins which will help you to remove the category word from wordpress URL.

I am using wordpress for long time. When wordpress 3.0 launched with multisite functionality we started using wordpress 3.0. Removing blog and category slug is very important for many clients.

Earlier also I written following article. But unfortunatly following code is not working now in newer release of wordpress.

https://purabtech.in/remove-blog-word-permalink/

Following wordpress plugins are useful:

WP No Category Base

As the name suggests this plugin will completely remove the mandatory ‘Category Base’ from your category permalinks ( e.g. myblog.com/category/my-category/ to myblog.com/my-category/ ).

The plugin requires no setup or modifying core wordpress files and will not break any links. It will also take care of redirecting your old category links to the new ones.

Manual method

Just add following code into your .htaccess file which you find in wordpress root folder.
RewriteRule ^category/(.+)$ http://www.site.com/$1 [R=301,L]

My suggestion:

Do not use any plugin or code for removing the category slug. If your client forces you to remove the category word then use wordpress permalink setting section. You can change the category slug from there. Following Note is given by wordpress.

Remove category slug wordpress
Remove category slug wordpress

“If you like, you may enter custom structures for your category and tag URLs here. For example, using topics as your category base would make your category links like http://example.org/topics/uncategorized/. If you leave these blank the defaults will be used.”

You can keep any slug name instead of category word.

block proxy servers to access wordpress

WordPress is always very target for hackers. Hackers always use the proxy servers to access the wordpress websites. Hackers attack the wordpress sites using the proxy IP addresses and servers. Here Using small trick you can prevent the proxy server attack. This is very easy trick which can be used in every wordpress project.

block proxy servers to access wordpress

All proxy visits are not bad requests so First check the site access logs. If you are thinking Your site attacked by Hackers and proxy servers then only use the following code.

 

You just need to add following code into your .htaccess file. You can open your .htaccess apache configuration file from wordpress root folder.

# BLOCK PROXY VISITS
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:VIA}                 !^$ [OR]
RewriteCond %{HTTP:FORWARDED}           !^$ [OR]
RewriteCond %{HTTP:USERAGENT_VIA}       !^$ [OR]
RewriteCond %{HTTP:X_FORWARDED_FOR}     !^$ [OR]
RewriteCond %{HTTP:PROXY_CONNECTION}    !^$ [OR]
RewriteCond %{HTTP:XPROXY_CONNECTION}   !^$ [OR]
RewriteCond %{HTTP:HTTP_PC_REMOTE_ADDR} !^$ [OR]
RewriteCond %{HTTP:HTTP_CLIENT_IP}      !^$
RewriteRule .* - [F]
</IfModule>

After adding above code you must check your wordpress site. Check the your every pages of your site. Check your sites pages on atleast on three PCs so you will sure about your site and above code.

Open your header.php file which you find in your wordpress theme folder.

Take backup header.php file first.

<?php if(@fsockopen($_SERVER['REMOTE_ADDR'], 80, $errstr, $errno, 1)) die("Proxy access not allowed"); ?>

Put above code in header.php file and check your site is working fine. There are so many articles written on same topic so you can check those also before making any changes.

block proxy servers to access wordpress
block proxy servers to access wordpress

change wordpress permalink to post name without losing traffic

Earlier I used date and name permalink structure for my blogs. Recently I got information about SEO URL tricks and I made decision to change permalink structure to Post name.  Here we shown how to change wordpress permalink to post name without losing traffic.  redirect to 404. interlinked other posts. They will go to 404 page.

change wordpress permalink to post name without losing traffic

change wordpress permalink to post name without losing traffic
change wordpress permalink to post name without losing traffic

So I changed permalink from:

https://purabtech.in/%year%/%monthnum%/%day%/%postname%/

to:

https://purabtech.in/%postname%/

It was very simple to above changes through wp admin->settings->permalink.

But with this produced many issues. Like google search result will go to old site URLs and My blog links are posted on other multiple blogs. That links will be broken and redirect to 404. Also I interlinked my other posts with other posts. They will go to 404 page.

If your blog pages will not found then google site ranking will go down.

By default in wordpress links look like /index.php?p=1234 which are not very useful for visitors or search engines.

In this walkthrough we’ll guide you through changing that to something useful like /post-title/.

Here I will tell you without loosing trafic or SEO how can you change the wordpress permalink day and name to post name

First go to wp admin->settings->permalink section and change setting to post name

If you are using any caching plugin (w3-cache or wp super chache) then remove all cache from dashboard.

Last edit .htaccess file and put following code there. Change domain name to your site name.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RedirectMatch permanent ^/[0-9]{4}/[0-9]{2}/[0-9]{2}/([a-z0-9-/]+) http://digcms.com/$1
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

When would you want to use the other permalink settings?

  • If you’re a news site, the Day and name or Month and name option lets visitors know when the content was published.
  • Google News requires you to have a minimum of 3 numbers in your article URLs. The date-based options achieve this.
  • If you have a lot of content on your website covering a wide range of topics, using categories in the URL can provide context. For example, /shows/big-bang-theory/ and /science/big-bang-theory/ are two very different things. This works best when you choose only 1 category for your posts.

Useful article

The perfect WordPress SEO permalink structure

change author url without wordpress plugin

wp user want to use other url for admin user. You can easily change using wordpress hook. you can change author url in wordpress without wordpress plugin. using code you can do this. wordpress developer can use this code.

change author url without wordpress plugin

There is default username in wordpress. admin is default username in wordpress but many times user want to use other wordpress user url for admin user. You can easily do this by using following wordpress hook.

You just need to place following code in functions.php file which is your theme folder.

add_action('init', 'change_wordpress_author_url');
function change_wordpress_author_url() {
global $wp_rewrite;
$author_slug = 'new_author_url';
$wp_rewrite->author_base = $author_slug;
}

You need to choose your author url. Just replace the “new_author_url” word and put in functions.php file.

change author url without wordpress plugin
how to change the author url in wordpress without wordpress plugin

comment Author URL is bigger in WordPress

Spam comments are most irritating for bloggers. Reading the all comments and their content and desire. If Comment author URL is bigger then you should consider that comment as Spam comment for sure. Many times I observed, spammer always try to add their site URL in Author URL.

comment Author URL is bigger in WordPress

Using following code you can protect your site from spam commenters. Open your functions.php file from your theme folder and just copy/paste the following code into that.

Following code will automatically mark the comments as spam where author URL is longer than 60 chars.

function wpapi_bigger_url_spamcheck( $approved , $commentdata ) {
return ( strlen( $commentdata['comment_author_url'] ) > 60 ) ? 'spam' : $approved;
}

add_filter( 'pre_comment_approved', 'wpapi_bigger_url_spamcheck', 99, 2 );

Above code is very important for wordpress bloggers. Every wordpress blogger should add the above code into their site.

Spam comments If comment Author URL is bigger in WordPress
Spam comments If comment Author URL is bigger in WordPress

Adding SVG upload functionality to WordPress site

SVG format is very important for chants and graphs. For admin orientated sites. There are many HTML admin templates which purely based on svg format. In HTML5 format SVG based graphs are too important. SVG is a language for describing two-dimensional vector graphics in XML. SVG stands for Scalable Vector Graphics.SVG defines graphics in XML format.

What is SVG?

  • SVG stands for Scalable Vector Graphics
  • SVG is used to define vector-based graphics for the Web
  • SVG defines the graphics in XML format
  • SVG graphics do NOT lose any quality if they are zoomed or resized
  • Every element and every attribute in SVG files can be animated
  • SVG is a W3C recommendation
  • SVG integrates with other W3C standards such as the DOM and XSL

SVG Advantages

Advantages of using SVG over other image formats (like JPEG and GIF) are:

  • SVG images can be created and edited with any text editor
  • SVG images can be searched, indexed, scripted, and compressed
  • SVG images are scalable
  • SVG images can be printed with high quality at any resolution
  • SVG images are zoomable (and the image can be zoomed without degradation)
  • SVG is an open standard
  • SVG files are pure XML

svg format is You can add this support by adding following in your functions.php file which you find in your wordpress theme folder.WordPress uploader does not support of SVG format files. Adding SVG upload functionality to WordPress. using our code your can use svg functionality in wordpress.

Adding SVG upload functionality to WordPress site

After adding following code you will be able to upload the svg file into your wordpress site or blog.

add_filter('upload_mimes', 'wpapi_upload_mimes');

function wpapi_upload_mimes($mimes = array()) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
Adding SVG upload functionality to WordPress site
Adding SVG upload functionality to WordPress site

how to crop uploaded image in wordpress without plugin

Many people use the scaled image for thumbnail image. Instead of that croping image the proper size and showing that is nice. Crop Uploaded image without plugin is supported by wordpress itself so do not use any third-party plugin for this.

crop uploaded image in wordpress

You can use the following code in your functions.php file:

// Standard Size Thumbnail
if(false === get_option("thumbnail_crop")) {
 add_option("thumbnail_crop", "1"); }
 else {
 update_option("thumbnail_crop", "1");
 }

// Medium Size Thumbnail
if(false === get_option("medium_crop")) {
 add_option("medium_crop", "1"); }
 else {
 update_option("medium_crop", "1");
 }

// Large Size Thumbnail
if(false === get_option("large_crop")) {
 add_option("large_crop", "1"); }
 else {
 update_option("large_crop", "1");
 }
crop uploaded image in wordpress without plugin
crop uploaded image in wordpress without plugin

Search result is single than redirect to wordpress post

Users always use the search the keywords in wordpress sites. Many times clients wish about this functionality. If there is only one result came from search result than user should redirect to single landing post.

Search result is single than redirect to wordpress post

If there is Search result is single then redirect to wordpress should redirect to single landing post.

You should open the functions.php file and  put following code in functions.php file.

<pre>add_action('template_redirect', 'redirect_single_post');
function redirect_single_post() {
    if (is_search()) {
        global $wp_query;
        if ($wp_query->post_count == 1) {
            wp_redirect( get_permalink( $wp_query->posts['0']->ID ) );
        }
    }
}
Search result is single than redirect to wordpress post
Search result is single than redirect to wordpress post

show related posts wordpress without plugin using category

How to show related posts wordpress without plugin using category. Showing related article in wordpress site is always good for users to attract visitors.  In many blogs people are showing the related or linked articles. Showing similier or related articles will increaze your site SEO. show related posts without wordpress plugin using category in wordpress site is always good for users to attract the visitors.

show related posts wordpress without plugin

More visitor will visit your site. For showing the related articles you need copy following code into your functions.php file.

[viral-lock message=”Code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]

// "Similier Articles"
function wpapi_more_from_cat( $title = "Similier Articles:" ) {
    global $post;
    // We should get the first category of the post
    $categories = get_the_category( $post->ID );
    $first_cat = $categories[0]->cat_ID;
    // Let's start the $output by displaying the title and opening the <ul>
    $output = '<h3>' . $title . '</h3>';
    // The arguments of the post list!
    $args = array(
        // It should be in the first category of our post:
        'category__in' => array( $first_cat ),
        // Our post should NOT be in the list:
        'post__not_in' => array( $post->ID ),
        // ...And it should fetch 5 posts - you can change this number if you like:
        'posts_per_page' => 5
    );
    // The get_posts() function
    $posts = get_posts( $args );
    if( $posts ) {
        $output .= '<ul>';
        // Let's start the loop!
        foreach( $posts as $post ) {
            setup_postdata( $post );
            $post_title = get_the_title();
            $permalink = get_permalink();
            $output .= '
<ul>
	<li>permalink . '" title="' . esc_attr( $post_title ) . '">' . $post_title . '</li>
</ul>
';
        }
        $output .= '</ul>';
    } else {
        // If there are no posts, we should return something, too!
        $output .= '<p>Sorry, this category has just one post and you just read it!</p>';
    }
    echo $output;
}

[/viral-lock]

After that open your single.php file and use following code.

wpapi_more_from_cat();
show related posts wordpress without plugin
show related posts wordpress without plugin

Using above code you can show the related articles in your wordpress site.