WordPress

How To Create a New Role in WordPress?

WordPress integrates six default roles: Administrator, Editor, Contributor, Author, subscriber and sixth multi-role: Super Admin which have all privileges under WordPress blog.

In this tutorial we will see how to create a new role for your website subscribers and how to display the content according to the new role.

Why would you need to create a new role in WordPress blog?
Apart from enhancing the WordPress security, we could give you a lot of reason to create a new role for subscribers. However in this tutorial we will give you one good example on how to keep the default subscriber role but also create a premium subscription to monetize your blog. So if you have a blog where you want to give access to certain articles or special offers only to people to have paid monthly subscription for example, they can have this custom-built new role in WordPress blog.

To create this new role (Premium Subscription) in WordPress you will need to add the following code in function.php file of your WordPress theme:

// Add a role
add_role(‘premium_user’, ‘Premium Subscription’, array(
‘read’ => true, // true : Allow reading of article page
‘edit_posts’ => false, // false : Forbidden to add articles or pages
‘delete_posts’ => false, // false : Forbidden to remove articles or pages
));

Add_role : premium_user identifier will be our new role and Premium Subscription is the name of the role that I attribute to my future subscribers who want this subscription.

Disable Plugin Update

How To Disable Plugin Update in WordPress?

If you have created your own WordPress theme for your blog and you have installed many different plugins, you are most probably facing with the problem when updating those plugins because once you do that you will change your theme and erase all your previous work/changes you’ve done, By using two codes below you can disable all update for all plugins or only select those who should not be updated.

The first method you can implement will disable all updates to your plugins. Copy and paste below code inside your funtion.php file.

remove_action( ‘load-update-core.php’, ‘wp_update_plugins’ );
add_filter( ‘pre_site_transient_update_plugins’, create_function( ‘$a’, “return null;” ) );

The second code will allow you to choose plugins that should not be updated. Add below code in your function.php file.

For this tutorial I decided to disable Akismet plugin. With below 3 line of the code I mentioned the name of the plugin, folder with the name of the php file that usually has the same name as the folder.

You can duplicate below lines of code and replace necessary values with plugin whos updates you want to block..

function stop_plugin_update( $value ) {
unset( $value->response[‘akismet/akismet.php’] );
return $value;
}
add_filter( ‘site_transient_update_plugins’, ‘stop_plugin_update’ );

WP_Query

How To Create WordPress Custom Queries with WP_Query?

WordPress custom queries are very powerful tool. If you want to display on your index.php or single.php file other content different from what the WordPress shows by default, just create WordPress custom queries using WP_Query. For those that don’t know, WP_Query is a class that allows you to create WordPress custom queries and retrieve your posts according to criteria defined via the parameter to the constructor of this class.

To use this application you must store it in a variable and use that object in WordPress loop. In this tutorial I will show you some great examples on how to use WordPress custom queries or WP_Query in your own WordPress projects.

WordPress Custom Queries Examples
This class can be configured as desired, and there are many possibilities available to you, here are some of WordPress custom queries examples I find most useful:

Example 1: Select all posts

$query = new WP_Query(array(‘post_type’ => ‘post’));

Example 2: Select all posts and all pages

How To Activate WordPress Links Manager? – WordPress 3.5

If you install WordPress 3.5 from scratch – without an update from an earlier version, you will no longer have the Links Manager and blogroll. Considered outdated and out of step with aspects of WordPress CMS, this link management tool can be easily reactivated in WordPress 3.5. That’s why we will show you how to activate WordPress Links Manager again and use it on your blog.

If you trying to reach the URL: http://example.com/wp-admin/link-manager.php, you will get an error message prompting you to download the WordPress Links Manager plugin.

WordPress Links ManagerWith WordPress Links Manager you were able to store a set of external links, or better known as blogrolls. These link you can put inside categories, they can be imported or exported, deleted…

Since the plugin does not contain a line of code, I suggest you to copy/paste directly into functions.php file of your theme, or better yet, to use global functions file (to avoid dependence of the theme).

Secure WordPress Blog – How to Achieve it?

Enhancing the WordPress security is an essential step in the creation of your secure WordPress blog. First of all you should know that 100% secure WordPress Blog or 100% security does not exist on the Internet nor in any field. Often when these problems occur we tend to think that the host is responsible, but its not. The host is a bit like the owner of a building who rents apartments. It will ensure that the amenities of bases related to the proper functioning of all are respected, but it can not be held responsible if you lose your keys or if you do not have a alarm system.

You still need to know that WordPress is very safe content management software but even this system can be hacked so thats why you need to secure WordPress blog. The problem of hacking is endless and unfortunately I found that on hard way because few weeks ago, my blog was hacked. And because no one is safe I’ll give you some tips which you can apply in order to have secure WordPress blog against attacks. This will also involve some plugins installation, but don’t worry all of them are free except the last two which are with good reasons payable options. Now, let’s begin with this list.

1. Password management

WordPress installation need 3 types of passwords: one for FTP, one for database, and one to connect to the WordPress admin section. It is obvious that most of these passwords are transferred between many people and with that the risks of getting hacked because of lost password are incresed. Tip: If one of your colleagues, employees, vendors terminates its relationship with your project, change these passwords. Also in order to secure WordPress blog, make sure you use strong passwords which include uppercase, lowercase, numbers, special characters…