Blog – Page 3

Create Users Programmatically

You can create a WordPress user programmatically using either wp_create_user() or wp_insert_user() functions, so in this tutorial I am going to show you the difference between them and we’re also going to take a look at several examples.

There is also a way how you can do that with SQL-requests but it is not exactly creating users programmatically, so we’re not going to uncover it in this tutorial, but you can read more here.

How to Create a Language Redirect in Multisite

Recently I got a request from my client and what she was needed is to automatically redirect users to a language-specific store within the WordPress multisite network depending on a customer IP address.

For example:

  • no.example.com – redirect customers here if they have a norwegian IP address,
  • dk.example.com – redirect customers here if they have a danish IP address,
  • example.com – let customers to stay on this website if there is no specific language website version for them (based on their IP again).

What is the easiest way to accomplish it?

How to Create Custom WP-CLI Commands

Recently I’ve been improving my Simple WordPress Crossposting plugin with some custom WP-CLI commands and got a thought in my mind – “why not create a tutorial about that?”

So here it is, below I am going to show you different examples of custom WP-CLI commands with subcommands, arguments and flags.

Tapping into switch_to_blog() Function Performance

It just happened that in my WordPress-related work I focused mostly on WordPress Multisite. I had a couple of big client projects in the past, then I developed WordPress plugins for multisite specifically, for example this one or this another one and here we go.

So I have quite a picture in my mind how the things should work the best.

In this tutorial I am about to talk about switch_to_blog() function, especially about its usage within a loop:

  • How does it work exactly?
  • Is it slow?
  • Can we improve it somehow?

First of all let me show you a code snippet I am talking about.

Importing Products in Multisites

Recently I was testing my new plugin related to a multisite network of WooCommerce stores and noticed that before doing a product import into one of the stores in a network you first need to do some additional network configuration.

I mean if you just go to a product import and try to upload a CSV file for example, you will definitely get an error like that:

product import error when importing WooCommerce product in a Multisite network
Trying to upload a CSV or TXT import file will cause this error when running a WooCommerce store within a multisite network. The error message can be like on the screenshot “Sorry, you are not allowed to upload this file type” or “Sorry, this file type is not allowed for security reasons”.

Understanding HPOS (High-Performance Order Storage)

In this tutorial I would like to guide you through the High-Performance Order Storage (HPOS) feature in WooCommerce – how to turn it on for your store, how it may affect it and how to update your plugins in order to make them work with the latest WooCommerce versions.

How to Copy a Page from One WordPress Site to Another

In this tutorial I would like to cover two ways how you can copy a WordPress page from one site to another. I am not going to use the export and import approach, because I think it is too complicated and requires extra steps which we normally don’t need.

And of course everything in this tutorial applies not only to regular WordPress pages, but also:

  • pages with tons of custom fields (ACF, Carbon Fields, Simple Fields etc),
  • pages, created with page builders (Elementor, WPBakery, Beaver Builder etc).
  • pages, created with either classic or the block editor.

So let’s get started now.