The Ultimate Guide to Creating a Custom CRM in WordPress

WordPress is amazing!  I’ve said it before and I’ll say it again, but WordPress is absolutely amazing.  The ability to create custom solutions with ease is unparalleled, and not only that but the fact that there are hundreds upon thousands of developers working with the platform at any one time, developing ready made solutions for common problems is a major game changer.  Gone are the days where you would have to expect to pay a custom dev a small fortune to get something as simple as a payment gateway added to your site.

But as wonderful as this all sounds, it doesn’t mean that a premade solution exists for every potential problem.  Sometimes you’ll still need a custom developer to work their magic, whether it’s just a small tweak here and there to how something premade works for whether it’s creating something from scratch.  In this article we’re going to look at creating your own custom CRM (customer relationship management) tool and plugin.

Why Build a Custom CRM?

So it’s true, there are a lot of customer relationship management plugins available for WordPress and WooCommerce, in fact, you could even argue that WordPress has it’s own inbuilt solution; the Users section.  And by no means am I suggesting that what’s available on the market right now is rubbish and should be avoided, not at all.  This article is aimed more towards the few that need to capture and retain specific information and details on their customers or clients, such as the case for a website that we recently built and is featured on our portfolio page, The Osteo Clinic.

If you’re looking for a reasonable and free CRM or ERP system that integrates directly into your WordPress website, and that you can run through WordPress, then take a look at these options.

1. WP ERP: a powerful WordPress plugin with a prebuilt Contact Form 7 integration for lead forms. WP ERP comes with 3 modules, one for customer relationship management, another for human resource management and an accounting module.

2. Ukuu People: a simple but power WordPress CRM plugin that can integrate with a variety of plugins and lead generation tools such as Gravity Forms and MailChimp.

About the Author

Founder

I’ve always believed that each business is unique. Bringing this view to Mars Digital means we take the time to understand you and your business before going away, doing the research and coming back to you with our thought out recommendations and the reasoning behind them.

For me, it’s all about building a mutually beneficial partnership.

Our Work

Destination Orewa Beach
Destination Orewa Beach

Destination Orewa Beach

Comprehensive Care
Comprehensive Care

Comprehensive Care

Coast Residential
Coast Residential

Coast Residential

Cain Built
Cain Built

Cain Built

Daylite Skylights
Daylite Skylights

Daylite Skylights

3D Online
3D Online

3D Online

JC Project Consulting
JC Project Consulting

JC Project Consulting

Taxi Tax
Taxi Tax

Taxi Tax

Trident Electrical & Air Conditioning
Trident Electrical & Air Conditioning

Trident Electrical & Air Conditioning

Zakmir
Zakmir

Zakmir

Hibiscus Coast Panel Beaters
Hibiscus Coast Panel Beaters

Hibiscus Coast Panel Beaters

Stella Beauty
Stella Beauty

Stella Beauty

Osteo Clinic
Osteo Clinic

Osteo Clinic

When Nothing Premade Exists

On the off chance that WP ERP or Ukuu People, or the multitude of other CRMs out there, whether built specifically for WordPress or not, don’t meet your criteria, you can always build your own.  And that is exactly what we did for the Osteo Clinic.  In that case a premade solution did exist, and it was a tried and true solution, but there were two major downfalls.  The first, it didn’t have a simple integration with WordPress  and would require a custom integration or to only be used externally.  The second was a massive ongoing monthly cost associated to the CRM package.

So we set out on creating a custom designed custom relationship tool integrated seamlessly into WordPress and the website itself.  Now you know when creating your very own CRM might become essential as opposed to utilising something that already exists, the rest of this article will show you exactly how to do it.

Steps 1 – 4: Create the Plugin Files

Ok, this is the hard part.  Once you get past this you’ll find the rest of this a walk in the park, but the first thing you need to do is to create the plugin files.  This is going to tell your WordPress installation two things: that a plugin exists, and what to do about it.  To do this you’re going to need access to your websites hosting and file manager.  FTP access is pretty common and you should be able to get this from any reasonable hosting company, not just us.  Once you’ve got access to your file manager your going to need to follow this path.

–> httpdocs –> wp-content –> plugins

In this folder you should find a list of all the plugins you have installed on your WordPress site, active or not.  The following steps can be done directly through a hosting platform such as Plesk but if you’re running an FTP client such as FileZilla you might find it easier to do this on your computer and then drag the files into the right folder.

 

The Directory & Code to Create Your Custom CRM

  1. Create a new directory and call this anything you like, in this example I’m calling it Mars Digital CRM
    This is the folder that will house the files you need in order to make your CRM system work.
  2. Open the directory and create a new file, add the name and end the file name by adding the extension .php
    In this example I’ve given the file the name mars-crm, again you can call it anything you like, however make sure you use a – instead of a space, and always end the name with .php
  3. Open the .php file you just created.
    Now you’ve created the .php file which tells WordPress where to look, we need to tell it what to do.
  4. Add the code below.
    By now you should have the .php file open in a code editor or text editor such as NotePad.  Copy the code below and paste it into your .php file and hit save.

The Code

Copy and paste the following code into your .php file that you created in the steps above.  This is the base of your CRM plugin and tells your WordPress site to create a new Post Type called Clients.  Of course you can use a Find & Replace function to change the term “Clients” to anything you like, you can use Patients, Customers, Leads, it’s completely up to you.  But if you change it, make sure you change all of them and change the term Client as well.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
* Plugin Name: Mars Digital CRM
* Plugin URI: #
* Version: 1.0
* Author: Mars Digital
* Author URI: https:// marsdigital.co.nz
* Description: A custom CRM system by Mars Digital
* License: GPL2
*/class WPMarsCRM {
/**
* Constructor. Called when plugin is initialised
*/
function __construct() {
add_action( ‘init’, array( &$this, ‘register_custom_post_type’ ) );
}/**
* Registers a Custom Post Type called client
*/
function register_custom_post_type() {
register_post_type( ‘client’, array(
‘labels’ => array(
‘name’               => _x( ‘Clients’, ‘post type general name’, ‘mars-crm’ ),
‘singular_name’      => _x( ‘Client’, ‘post type singular name’, ‘mars-crm’ ),
‘menu_name’          => _x( ‘Clients’, ‘admin menu’, ‘mars-crm’ ),
‘name_admin_bar’     => _x( ‘Client’, ‘add new on admin bar’, ‘mars-crm’ ),
‘add_new’            => _x( ‘Add New’, ‘client’, ‘mars-crm’ ),
‘add_new_item’       => __( ‘Add New Client’, ‘mars-crm’ ),
‘new_item’           => __( ‘New Client’, ‘mars-crm’ ),
‘edit_item’          => __( ‘Edit Client’, ‘mars-crm’ ),
‘view_item’          => __( ‘View Client’, ‘mars-crm’ ),
‘all_items’          => __( ‘All Clients’, ‘mars-crm’ ),
‘search_items’       => __( ‘Search Clients’, ‘mars-crm’ ),
‘parent_item_colon’  => __( ‘Parent Clients:’, ‘mars-crm’ ),
‘not_found’          => __( ‘No clients found.’, ‘mars-crm’ ),
‘not_found_in_trash’ => __( ‘No clients found in Trash.’, ‘mars-crm’ ),
),// Frontend
‘has_archive’ => false,
‘public’ => false,
‘publicly_queryable’ => false,// Admin
‘capability_type’ => ‘post’,
‘menu_icon’ => ‘dashicons-businessman’,
‘menu_position’ => 10,
‘query_var’ => true,
‘show_in_menu’ => true,
‘show_ui’ => true,
‘supports’ => array(
‘title’,
‘author’,
‘comments’,
),
) );
}
}$wpMarsCRM = new WPMarsCRM;

The Wonderfully Easy Part

If you’ve got to this point and you’ve followed the instructions above to the letter you should have something that looks like the screenshots below this paragraph.  There should be a new plugin listed on your WordPress plugins page named Mars Digital CRM or whatever name you gave yours.  Now make sure you activate it.  Once you do that you should see Clients, or your term, appear down the left hand side of your WordPress admin menu.  If you see this, then, well done!

That’s the hard part.  Everything from here is a piece of cake, a walk in the park.  What you’ve just done is told WordPress to create a custom post type based on the name you specified in the plugin file.  Now if we were looking at producing a ridiculously complex CRM system chances are we’d need a lot more hand written code like what you copied and pasted already.  But in this tutorial we’re focusing on creating a simple CRM that you can customise to your needs.  One that allows you to easily find and store the data that you want to capture.

From here the rest of the steps are really all about ACF.  Advanced Custom Fields is a brilliant WordPress plugin that allows you to easily create various inputs, selections and file upload fields for WordPress post types such as WooCommerce Orders or Products, Users, and in the case the Clients post type you just created for your CRM in steps one through four.

 

Installing Advanced Custom Fields

First you’re going to need to decide if you need the premium version of ACF or if you can get away with just the free version.  If you only need the free version then follow these steps:

  1. One your WordPress Dashboard, click on Plugins and Add New.
  2. Use the Search bar and type Advanced Custom Fields.
  3. The first one that comes up should have over a million active installs and the author credited as Elliot Condo, this is the one you want.  Click Install and Active once it’s done.

How do you know if you need the free or pro version of ACF?  The difference between the two is pretty simple, the free version of ACF is the base plugin, ACF Pro (the premium version) comes with four premium addons that you can utilise.  These are:

  1. Repeater Field – this is probably going to be the most handy of the four as it allows you to create a set of fields that can be repeated again and again while editing content.
  2. Flexible Content Field – this acts as a blank canvas where you can add an unlimited number of layouts. Perfect for building WordPress themes.
  3. Gallery Field – this is probably more suited for front end development but provides a simple interface for managing images.
  4. Options Page – this provides a set of functions to add extra admin pages to edit ACF fields.

 

Using Advanced Custom Fields

All the fields in the screenshot you saw at the beginning of this article were created using ACF.  The only coding that was needed was demonstrated in steps one to four.  And using Advanced Custom Fields to make a custom WordPress CRM is extremely simple.

If you’ve activated the plugin you’ll see a new admin menu option appear down the left hand side of your WordPress backend called Custom Fields.  Click on that.  Once you’ve navigated your way to the ‘Field Groups’ section of ACF you can start created your CRM components and fields.  The first once we’re going to look at is the Quick Details section in the screenshot.  However, in case it’s too difficult to read, this is the Quick Details section.

The Quick Details Section

Step 1:

Create a new Field Group and call it something like Quick Details.  This is the section that we’re going to add to the right hand side of the Client’s page inside the CRM.  It’s good for things like quick notes, contact details, status tags such as VIP and whatever else is important to your business.

Step 2:

Now that the Field Group is created you just need to assign it to the custom post type you created.  To do this find the section labelled ‘Location’.  Here you want to add a rule that states the following: Show this field group if Post Type is equal to Client (or whatever you’ve called your post type).  If you’ve done that correctly it should look something like this.

Step 3:

Scroll a little further down the Field Groups page and you’ll find a section called ‘Settings’.  Here you can make choices about what the fields look like and where they’re placed.  In this example, because we’re creating the Quick Details section we’re going to look at the ‘Position’ setting.  This should be set to ‘Side’.  This will pop your field group to the right hand side of the main page just like in the screenshot at the beginning of the post.

We’re also going to want to have the group marked as ‘Active’, you can always turn it off at a later point if you don’t want to see the fields temporarily but for development we’ll leave it on so you can see your progress.

Step 4:

All that’s left now is to create the fields.  For a Quick Details section like this there shouldn’t be anything to complicated so it should be a simple matter of clicking ‘Add Field’, typing in the name you want to give that field, selecting the type; meaning text, number, email, image, checkbox etc etc and deciding whether you want to make an answer for that field compulsory.  NB: you don’t have to add anything in the remaining boxes, but you can if you want to.

Step 5:

Repeat step 4 as many times as you need and add in all the fields you want to display in this section.  Once you have all the fields you need to add here click on the Publish button near the top of the page on the right side.

Creating Your Primary Sections & Fields

This part is a bit more detailed and has more steps to itg before you get it right.  There’s also a huge number of options that you can utilise to make your own, but in this tutorial we’ll look at creating something similar to the screenshot from the beginning of the article in terms of both design and functionality.

That means we’re going to create a new field group for the main section of our Clients post type and then populate it with various tabs to add important information such as company name, position, preferred name and preferred method of contact.

We’re even going to add a linked clients section where you can show things like parent companies, or mark referring clients.

 

The Primary Details Section

Step 1:

Just like the first step for the Quick Details section you need to create a new Field Group and call it something like Client Details.  This is the section that we’re going to add to the main section of the Client’s page inside the CRM and where we’re going to store all the information we need and want at our fingertips.

Step 2:

Again this is very much the same as the second step above.  You’re going to need to assign the field group to the custom post type you created.  To do this find the section labelled ‘Location’ and add a rule that states the following: Show this field group if Post Type is equal to Client (or whatever you’ve called your post type).

Step 3:

This is where it starts to differ from the Quick Details section.  When you scroll a little further down the Field Groups page to the ‘Settings’ area instead of selecting side, we’re going to select ‘Normal (after content)’.  If you’re going to have multiple field groups for the main section of your CRM you can use the ‘Order No.’ setting to decide which one displays before another.  In this case we’re marking this as the first section, so let’s give it a value of 1.

Step 4:

At this point, if you haven’t already done so, you need to think about the fields you need.  What information you want to store and how you want it structured.  Write it down and draw it out on a piece of paper.  This doesn’t have to be a lengthy process but if you do this it will help guide you through the next few steps as we create the fields and place them under different tabs and align them how we want.

Step 5:

It’s time to add a field and for the CRM we’re creating in this article we need to create a tab.  This tab is going to house all our contact details for the associated client.  To do this click on ‘Add Field’, give it a name such as Contact Details and then give it the field type layout ‘Tab’ and close the field.

Once you’ve done that we just need to add the fields for each of the contact details you want to collect.  In this case we’ve created fields for first name, middle name, last name, preferred name, preferred method of contact, phone number, email address and physical/postal address.  Each of these is added the exact same way we added fields earlier on, the only difference is that we’ve added a little design element to a couple of them.  Nothing spectacular but you may notice that the don’t all just fall one after the other, we have the three name fields on one line.  To do this we just need to utilise the ‘Wrapper Attributes’ setting when creating the field.  For the names section we wanted to have three equal sized sections side by side.  To do that it is a simple matter of adding ’33’ to the width under Wrapper Attributes.  If you wanted just two side by side like with Preferred Name and Preferred Method of Contact you can add the number 50 instead.  It’s just a percentage size.

Finishing Touches

More Tabs:

Once you’ve added all the fields into your first tab we need to close it off and start the second tab.  This is extremely straightforward and could be rather intuitive if you’re familiar with ACF in any way.  Realistically all you have to do is create another field as we did in step 5 above for the ‘Tab’ field.  This will create a new tab and all custom fields you place below this will appear under that tab in your CRM.

Field Groups:

In the example, you may notice what is referred to as a Field Group.  The section containing the address input clumps together multiple fields.  Again creating this is very straightforward.  Add a field and select the type “Group”, from there you will see a section called “Sub Fields” where you can add the address fields or whatever it is you need to add just like normal.

Conditional Logic:

This is when you want a field to display only if a particular answer is given to a previous question.  For example in we have a section for the new patients referral source.  If ‘Existing Client’ is selected another field appears allowing the user to search a list of all other clients to select the one who referred the new client.  Adding conditional logic fields is simple, add you field as normal, and select the box ‘Conditional Logic’ once you do this you are able to select which field and which answer input causes the new field to appear.

Summary

Creating your own simple CRM for WordPress can be a powerful tool that allows you to capture the information that is a must for you and your business.  And thanks to Advanced Custom Fields, it’s not too difficult to get it up and running.  Although it may be a little time consuming to get it right, creating your own CRM can do wonders for your business.

If you need help or advice creating your own simple CRM for WordPress, don’t hesitate to get in touch.  Mars Digital are here to help.

 

Marketing out of this world