Easy Guide to Add an Admin User to the WordPress Database via MySQL

In this article, we will show you a step by step guide on how to create an admin user in WordPress Database via MySQL.

Note: You should always make a backup of your database before performing any MySQL edits. This tutorial requires basic understanding of how phpMyAdmin works.

If you don’t like the video or need more instructions, then continue reading.

Step-01: you need to login to phpMyAdmin and locate your WordPress database. (Below is a screenshot of a HostGator cPanel)

Step-02: Once you are in, we will be making changes to the wp_users and wp_usermeta tables. Lets go ahead and click on wp_users table.

Step-03: We need to insert our new admin user’s information, so click on the Insert tab like it shows in the image above. In the insert form, add the following:

  • ID – pick a number (in our example, we will use the number 4).
  • user_login – insert the username you want to use to access the WordPress Dashboard.
  • user_pass – add a password for this username. Make sure to select MD5 in the functions menu (Refer to the screenshot below).
  • user_nicename – put a nickname or something else that you would like to refer yourself as.
  • user_email – add the email you want to associate with this account.
  • user_url – this would be the url to your website.
  • user_registered – select the date/time for when this user is registered.
  • user_status – set this to 0.
  • display_name – put the name you like to display for this user on the site (it can be your user_nicename value as well).
  • Click on the Go Button

Step-04: we are going to have to add the values to wp_usermeta table. Click on the wp_usermeta table and then click on the Insert tab just like the previous step. Then add the following information to the insert form:

  • unmeta_id – leave this blank (it will be auto-generated)
  • user_id – this will be the id of the user you created in the previous step. Remember we picked 4.
  • meta_key – this should be wp_capabilities
  • meta_value – insert this: a:1:{s:13:"administrator";s:1:"1";}

Insert another row with the following information:

  • unmeta_id – leave this blank (it will be auto-generated)
  • user_id – this will be the id of the user you created in the previous step. Remember we picked 4.
  • meta_key – this should be wp_user_level
  • meta_value – 10

Then click on the Go button, and you have created yourself a new username. Now you should be able to login to your wp-admin with the username and password you specified for this user. Once logged in, click on Users and edit the username you just created. Go down and click on the Save button (you don’t have to change anything). This will allow WordPress to go through and add some more information and clean-up the user we just added.

SQL query

For developers who want to speed this process up, you can simply drop this SQL query in your database.

1
2
3
4
5
6
7
INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'demo', MD5('demo'), 'Your Name', '[email protected]', 'http://www.test.com/', '2011-06-07 00:00:00', '', '0', 'Your Name');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_user_level', '10');

Remember to change the databasename to the database you are working with. Also don’t forget to change the appropriate values.

Easy Guide to Use FOMO on Your WordPress Site to Increase Conversions

In this article, we will show you how to properly add FOMO to your WordPress website and boost conversions.

 

What is FOMO and How it Helps with Conversions?

FOMO or ‘fear of missing out’ is a psychological term used to describe anxiety about missing out on something exciting and trendy.

As a website owner, you can take advantage of this human behavior with your marketing strategy and improve your conversions.

FOMO is nothing new, marketers have been using it way before the arrival of the internet. Now with online marketing, FOMO has become far easier to implement and much more effective.

For example, if you run an online store, then you can create anticipation about an upcoming sale, limited time offers, and by adding social proof to your landing pages.

You can also use it to build your email list, run affiliate marketing campaigns, boost downloads for your apps, and more.

That being said, let’s take a look at how to easily add FOMO to your WordPress site. We will show you two techniques that we have successfully used on our own sites with incredible results.

1. Adding FOMO with Social Proof by Using Proven

One way to ignite FOMO is by adding social proof to your website. It helps you instantly win user’s trust by showing them that other users are already buying your product.

 

First, you need to install and activate the Proven plugin. For more details, see our step by step guide on how to install a WordPress plugin.

Proven is a social proof plugin that integrates with your eCommerce platformor MailChimp email lists and displays recent purchases and sign ups.

Upon activation, you need to head over to Proven » Settings page to enter your license key. You can find this information from your account on the plugin website.

Next, let’s head on over to the Proven » Add New page to create your first social proof notification.

First, you need to enter a title for this notification campaign. After that, you need to choose whether you want this configuration to be active or not. You can keep it inactive while you configure your settings, but don’t forget to change this setting to make your notifications live once you are done.

Next, you will come to the content section where you will be asked to select the source for your notifications.

Proven integrates with WooCommerce, MailChimp, and Easy Digital Downloads. When you integrate with one of these three, the social notification will automatically display the recent purchase and subscriber notifications.

You can also enter the source manually, which will allow you to manually create entries that will be displayed in the notification. This is particularly helpful when you are not using a shopping cart plugin on your website.

After that, you can change the content template using the available template tags displayed below the field.

For the purchases field, you need to select which product purchases are displayed in the notification. If you are integrating it with MailChimp, then you can choose which mailing list will trigger the notification.

Next, you can select when you want notifications to be displayed in the Behavior settings. You can select pages where you want the notification to appear, you can also select users, mobile view, the delay between notifications, and more.

Lastly, you will reach the ‘Appearance’ section. From here you can select colors, shape, and position of your notification banner.

Once you are satisfied with the settings, don’t forget to click on the ‘Publish’ button to make it live.

You can now visit your website to see the FOMO social proof notification in action.

Method 2: Adding FOMO Countdown Timers with OptinMonster

We have all seen marketers using ‘Urgency’ to get customer’s attention. Whether it is your local grocery store or a big name brand website, it is one of the oldest marketing techniques, which works just as effectively online.

Basically, you show users an offer with a sense of urgency, which triggers the fear of missing out a valuable deal and helps users make a purchasing decision.

Urgency hacks can be used with limited time offer, seasonal sale campaigns, one-time discounts, coupons, and more. To learn more, see this article on using urgency to hack conversion rates with proven methods.

Now, the thing is how do you use urgency with FOMO to create a powerful conversion magnet?

This is where OptinMonster comes in. It is the best conversion optimization software that helps businesses turn abandoning website visitors into subscribers & customers.

First, you will need to sign up for an OptinMonster account. It is a paid tool and you will need at least the ‘Plus’ plan to use their Floating bar campaigns.

Next, switch to your WordPress site to install and activate the OptinMonsterplugin. For more details, see our step by step guide on how to install a WordPress plugin.

This plugin is a connector between your WordPress site and the OptinMonster app.

Upon activation, click on the OptinMonster menu in your admin sidebar and enter your API key. You can find this information under your account on OptinMonster website.

After entering your API Key, you will need to click on the ‘Create New Campaign’ button to continue.

First, you need to select an optin type and then select a theme. We will be using a ‘Floating bar’ campaign with the ‘Countdown’ theme.

Next, you will be asked to choose a name for your theme and the website where you will run it. Filling this information will launch the OptinMonster Builder interface.

You need to click on the ‘Optin’ tab and select your countdown type and end date. There are two types of countdown timers you can use ‘Static’ and ‘Dynamic’.

The static timer remains the same for all your users, while the Dynamic timer changes based on user behavior on your website.

For this tutorial, we will be using the static timer. Since we are using floating bar with countdown theme, we can move the optin bar to the bottom or the top.

 

Now, go back to your WordPress website and click on the ‘Campaigns’ tab on the OptinMonster page. You will see your recently created campaign listed there (Click on refresh campaigns button if you don’t see it).

By default your campaign will be disabled, and you just have to click on the ‘Go Live’ link to enable it.

You can now visit your website to see your countdown timer FOMO campaign in action.

Tracking Your Conversions in WordPress

FOMO techniques work really well for conversions, but how do you keep track of their performance? Without tracking you wouldn’t know how many sales or leads were generated due to these campaigns.

All expert marketers use Google Analytics. It not only helps you see where your users are coming from, it also allows you to track user engagement on your website.

The easiest way to use Google Analytics in WordPress is through MonsterInsights. It is the best Google Analytics plugin for WordPress and has an eCommerce addon for WooCommerce and EDD, which helps you track your eCommerce performance without leaving WordPress.

We hope this article helped you learn how to add FOMO to your WordPress website and boost conversions. You may also want to see our list of must-have WordPress plugins for business websites.

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

Easy Guide to Set, Get, and Delete WordPress Cookies

In this ultimate guide, we will show you how to set, get, and delete WordPress cookies.

 

Editors Note: This is an advanced tutorial. It requires you to have proficient understanding of HTML, CSS, WordPress site, and PHP.

What Are Cookies?

Cookies are plain text files that are created and stored in users browser when they visit a website. Cookies are used to add different features on a website.

Following are some of the common usage of cookies on various websites.

  • Store and manage user’s login information
  • Store temporary session information during a users visit
  • Ecommerce stores use cookies to remember cart items during a user’s visit
  • Track user activity on a site to offer personalized user experience
  • and more

As you can see, cookies are highly useful tool for website owners, but they can also be a bit invasive. Recent trends in email marketing, growth hacking, and online marketing as a whole allow websites to set cookies that act as a beacon and can be used to store and even share user activity across websites.

This is why European Union enacted the EU Cookie Law, which requires website owners to declare that they use cookies to store information.

How Cookies are Used in a Typical WordPress Website

By default, WordPress uses cookies to manage logged-in user sessions and authentication. It also uses cookies to remember a user’s name and email address if they fill out a comment form.

However, many WordPress plugins on your website may also set their own cookies.

If you are using third party services on your website like Google Analytics or Google AdSense, then they may also set cookies on your website.

You can view all website cookies in your browser’s settings. For example, in Google Chrome you need to go to settings and search for ‘content settings’.

Content settings in Google Chrome

Under content settings, you will need to click on ‘Cookies’ to open the cookies settings page.

Next, you need to click on the ‘All cookies and site data’ option.

On the next page, you will see a list of all cookies and site data stored on your browser by all websites you visited.

You can type a website address in the search box, and it will show you the data stored by that website.

Clicking on a single item will show you more details about individual cookies and their contents.

How to Set a Cookie in WordPress

To follow this tutorial, you will need to add code to your theme’s functions.phpfile or a site-specific plugin. If you haven’t done this before, then please take a look at our guide on how to copy and paste code snippets in WordPress.

First we will use the setcookie() function in PHP. This function accepts the following parameters.

  • Cookie name
  • Cookie value
  • Expire (Optional: sets a time period after which cookie expires)
  • Path (Optional, by default it will use the site’s root)
  • Domain (Optional, by default uses your website’s domain)
  • Secure (Optional, If true then only transfers cookie data via HTTPS)
  • httponly (Optional, when set true the cookie is only accessible via HTTP and cannot be used by scripts)

Now let’s add a code snippet to your WordPress site. This code stores the exact timestamp when a user visited your website in a cookie.

function wpb_cookies_tutorial1() { 
 
$visit_time = date('F j, Y  g:i a');
 
if(!isset($_COOKIE[$wpb_visit_time])) {
 
// set a cookie for 1 year
setcookie('wpb_visit_time', $current_time, time()+31556926);
 
}
 
} 

You can now visit your website and then check your browser cookies. You will find a cookie with the name wpb_visit_time.

How to Get a Cookie and Use it in WordPress

Now that we have created this cookie that’s stored in user’s browser for 1 year, let’s take a look at how can we use this information on our website.

If you know the name of a cookie, then you can easily call it anywhere in PHP using the $_COOKIE[] variable. Let’s add some code that not only sets the cookie but also uses it to do something on your website.

function wpb_cookies_tutorial2() { 
// Time of user's visit
$visit_time = date('F j, Y g:i a');
 
// Check if cookie is already set
if(isset($_COOKIE['wpb_visit_time'])) {
 
// Do this if cookie is set 
function visitor_greeting() {
 
// Use information stored in the cookie 
$lastvisit = $_COOKIE['wpb_visit_time'];
 
$string .= 'You last visited our website '. $lastvisit .'. Check out whats new'; 
 
return $string;
}   
 
} else { 
 
// Do this if the cookie doesn't exist
function visitor_greeting() { 
$string .= 'New here? Check out these resources...' ;
return $string;
}   
 
// Set the cookie
setcookie('wpb_visit_time',  $visit_time, time()+31556926);
}
 
// Add a shortcode 
add_shortcode('greet_me', 'visitor_greeting');
 
} 
add_action('init', 'wpb_cookies_tutorial2');

We have commented the code to show you what each part does. This code uses the information stored in the cookie and outputs it using the shortcode. You can now add shortcode [greet_me] anywhere on your website, and it will show when a user last visited.

Feel free to modify the code to make it more useful for your website. For example, you can show recent posts to returning users and popular posts to new users.

Deleting a Cookie in WordPress

So far we have learned how to set a cookie and use it later in your website. Now let’s take a look at how to delete a cookie.

To delete a cookie, you need to add the following line to your code.

unset($_COOKIE['wpb_visit_time']);

Don’t forget to replace wpb_visit_time with the name of the cookie you are trying to delete.

Let’s put this code in some context using the same sample code we used above. This time we will delete a cookie and set it again with new information.

function wpb_cookies_tutorial2() { 
// Time of user's visit
$visit_time = date('F j, Y g:i a');
 
// Check if cookie is already set
if(isset($_COOKIE['wpb_visit_time'])) {
 
// Do this if cookie is set 
function visitor_greeting() {
 
// Use information stored in the cookie 
$lastvisit = $_COOKIE['wpb_visit_time'];
 
$string .= 'You last visited our website '. $lastvisit .'. Check out whats new'; 
 
// Delete the old cookie so that we can set it again with updated time
unset($_COOKIE['wpb_visit_time']); 
 
return $string;
}   
 
} else { 
// Do this if the cookie doesn't exist
function visitor_greeting() { 
$string .= 'New here? Check out these resources...' ;
return $string;
}   
}
add_shortcode('greet_me', 'visitor_greeting');
 
// Set or Reset the cookie
setcookie('wpb_visit_time',  $visit_time, time()+31556926);
} 
add_action('init', 'wpb_cookies_tutorial2');

As you can see, this code deletes the cookie once we have used the information stored inside. Later we set the cookie again with the updated time information.

We hope this article helped you learn how to easily set, get, and delete WordPress cookies.

Easy Guide to Fix Custom Fields Not Showing in WordPress

In this article, we will show you how to easily fix custom fields not showing issue in WordPress.

Fixing Custom Fields Not Showing Issue in WordPress

Custom fields are typically associated with WordPress post, pages, or custom post types. Often you will find custom fields mentioned in various WordPress tutorials around the web, but you will likely not see the custom fields option on your site specially if you recently started your WordPress blog.

In the past, custom fields were visible by default on the post edit screen of all WordPress sites. However since it is an advance feature, the WordPress core development team decided to hide custom fields by default for all new users in the WordPress 3.1 release.

They also made it easy for anyone to make them visible with just two clicks from within the post edit screen.

Simply create or edit an existing post / page, and then click on the ‘Screen Options‘ button at the top right corner of the screen. This will show you a menu with several options that you can show or hide on your post edit screen.

Go ahead and click on the checkbox next to ‘Custom Fields’ option.
Show custom fields

Note: If you don’t see the Custom Fields option on your site, then please scroll to the troubleshooting option below in the article.

You can now scroll down on the post edit screen, and you will notice a new meta box labeled ‘Custom Fields’ below your post editor.
Custom Fields box

Since WordPress remembers your display choice, it will continue to display the custom fields box whenever you are editing posts on your website.

You can use this box to add, edit, and delete custom fields and their values.

What are Custom Fields? What Can You Do with them?

By default, when you write a new post, page, or any content type, WordPress saves it into two different areas. The first part is the body of your content that you add using the post editor.

The second part is the information about that particular content. For example, title, author name, date / time, and more. This bit of information about the post is called metadata.

Apart from the default post metadata, WordPress also allows you to save custom metadata by using custom fields.

To learn more, see our beginner’s guide to WordPress custom fields with examples, tips, and tricks that you can use on your website.

WordPress developers use custom fields to store custom post metadata for your posts. For example, the Yoast SEO plugin uses custom fields to store SEO settings for your posts.
Yoast SEO meta box

However instead of using the default custom fields box shown above, these plugin developers create their own custom meta boxes. This makes it easier for users to input information.

If you want to create a custom meta box to easily input custom metadata, then see our guide on how to add custom meta boxes in WordPress.

Troubleshooting

Recently one of our readers came to us with a problem where the Custom Fields option was missing from the WordPress screen options. After some investigation, we were able to find the cause of the issue.

If your WordPress site is missing the custom fields option under the ‘Screen Options’ menu, then you need to check if you have the Advanced Custom Fields (ACF) plugin active on your site.

ACF is a very popular WordPress plugin that developers use to create custom meta boxes. ACF is running on over 1 million websites.

In ACF version 5.5.13, they added a setting to remove the default WordPress custom field metabox to speed up the load times on the post edit page. The idea being that you shouldn’t need the default metabox since you’re using ACF.

However if you need to have the default WordPress custom field metabox enabled, then you need to add the following code to your WordPress theme’s functions.php file.

add_filter('acf/settings/remove_wp_meta_box', '__return_false');

This will solve the custom fields option missing issue in WordPress.

We hope this article helped you fix the custom fields not showing issue on your WordPress site.

Easy Guide to Upload a HTML Page to WordPress without 404 Errors

In this article, we will show you how to properly upload a HTML page to your WordPress site without causing 404 errors.

Why Upload HTML Pages to WordPress?

WordPress comes with a built-in content type to add pages to your website. Often WordPress themes add pre-designed page templates to display your pages.

There are even WordPress landing page plugins that allow you to create beautiful page templates with a drag and drop builder.

This means that in most cases, you shouldn’t need to upload a HTML page to your WordPress site.

However, sometimes a user may have static HTML pages from their old website or a static template that they really like and want to use. In these scenarios, you will need to upload your HTML page to WordPress.

Since, WordPress comes with its own SEO friendly URL structure, it can cause a 404 error if you simply uploaded your HTML page and tried to access it.

That being said, let’s take a look at how to upload a HTML page to your WordPress site without causing 404 errors.

Uploading HTML Page to WordPress Site

Step -01: Before you upload your HTML page to the WordPress site, you need to make sure that the ‘index.html’ file is renamed to ‘index.php’.

HTML Template File

Step-02: After that, you need to add all files including the HTML page, CSS, and other folders to a Zip archive.

Step-03: Windows users can right-click and select Send to » Compressed Zip Folderoption to create a zip file. Next, simply drag and drop all files and folders for your HTML page to the zip file.

Zip Archive HTML Page

Mac users can select the parent folder containing all files and folders, and then right-click to select ‘Compress folder’ option.

Create zip file in Mac

Step – 04: Next, you need to go to the cPanel of your WordPress hosting account. In the cPanel, you need to scroll down to the Files section and then click on the File Manager app.

Step-05: Once you are in File Manager, you need to navigate to the website root folder which is usually called public_html and contains all your WordPress files folders. From there, you need to click on the Folder link from the top menu to create a new empty folder.

A popup will open where you need to add a name for the new folder. Use a name that you want to use as the URL of your HTML page and then click on the Create New Folder button.

Create zip file in Mac

Step -06: After creating the folder successfully, you need to open it and click on the Upload button from the top menu to select and upload the zip file you created earlier from your computer. You’ll see the progress bar while the zip file uploads to your site.

Once uploaded, you need to select the zip file and then click on Extract button from the top menu.

Step -07: You will be asked where to extract the files. Simply select the same new folder that you created and click on the Extract File(s) button.

File Manager will now extract the zip file, and you will be able to see files in your folder.

Note: You can now delete the zip file from here. It doesn’t affect your HTML page or any other folders that are extracted.

Create zip file in Mac

Step – 08: Now you can visit this page in the browser by using the name of the folder (For example, yourwebsite.com/example). If your server doesn’t support the redirection, then you may see a 404 error. It happens because your ‘index.php’ file is not redirected on loading the URL in browser.

It is one of the common WordPress errors and can be fixed easily.

Using the File Manager app, you need to edit .htaccess file in your website’s root folder and add the following code:

RewriteRule ^(.*)index\.(php|html?)$ /$1 [R=301,NC,L]

This code will redirect your ‘index.php’ file and load it in the browser. If you are using a case-sensitive name for a file or folder, then the above code will also redirect that to show you the content.

We hope this article helped you learn how to upload an HTML page to your WordPress site without 404 error.

Easy Guide to Automatically Change WordPress SALT Keys

In this article, we will show you how to automatically change WordPress SALT keys without any code.

What are SALT Security Keys?

Salt Keys aka security keys in WordPress are the variables that store your login credentials in an encrypted form. By default, WordPress saves your login information in cookies which given the right conditions can be compromised specially when using public computers.

One way to stay ahead of this risk is to change your security keys manually from your wp-config.php file that is available in the root folder of your WordPress site. The security and SALT keys will look like this:

Security Config Keys

We recommend changing these codes on a regular basis to improve your website security (every 3 – 6 months). You can manually generate the Salt keys from WordPress.org secret-key service.

While changing the keys manually isn’t hard, it’s still time consuming to manually edit a core file and upload via FTP. In case, you don’t have coding knowledge, or don’t have the time, then this solution is for you.

Let’s take a look at how easily you can set an automated process to change security and SALT keys in WordPress:

How to Change WordPress SALT Keys?

The first thing you need to do is install and activate Salt Shaker plugin. For more details, see our guide on how to install a WordPress plugin.

Once the plugin is activated, you need to go to Tools » Salt Shaker page in your WordPress admin to set a schedule for changing the SALT keys.

You need to check the option for automatically changing the Salt keys and then select your schedule from the dropdown. You can automatically change the authentication keys daily, weekly, and monthly.

In case you want to change the security and Salt keys manually, then you can do so by clicking on the Change Now button.

Note: Every time your WordPress SALT keys are changed, you and other users will be automatically logged out from your WordPress site on all devices. You can easily re-login to your WordPress dashboard by going to the WordPress login page.

We hope this article helped you automatically change the WordPress SALT keys.

Easy Guide to Use Shortcodes in your WordPress Sidebar Widgets

In this article, we will show you how to use shortcodes in your WordPress sidebar widgets.

 

What Are Shortcodes?

Shortcodes allow you to add dynamic items like contact form, tables, and others inside your WordPress content area.

You can also use shortcodes in your widgets to add these dynamic items in your sidebars and other widget-ready area.

Let’s take a look at how to easily add and use shortcodes in your WordPress sidebar widgets.

Method 1: Adding Shortcode in WordPress Sidebar Using Text Widget

First thing you need to do is drag & drop a Text widget to your WordPress sidebar on the Appearance » Widgets screen in your dashboard. After adding the widget, you can simply add your shortcode inside the text edit area of the widget.

Don’t forget to click on the ‘Save’ button to store your widget settings.

You can now visit your website and see the shortcode in action.

Method 2: Adding Shortcode in WordPress Using Custom HTML Widget

Sometimes you may want to add custom HTML code around your shortcode which may not work so well in the plain text widget. In that case, you will need to add your shortcode using the ‘Custom HTML’ widget.

By default, shortcodes are not allowed to be executed in a custom HTML widget. To change this, you will need to add the following code to your theme’s functions.php file or a site-specific plugin.

add_filter( 'widget_text', 'do_shortcode' );

After that, you can simply add a ‘Custom HTML’ widget to your sidebar and add your shortcode inside it.

Don’t forget to click on the save button to store your widget settings.

You can now visit your website to see your shortcode in action.

We hope this article helped you learn how to easily add shortcode to your WordPress sidebar widgets.