WordPress
Prerequisites
To install the plugin in WordPress, your PHP environment needs the following:
-
At least version 5.6.20.
-
SSL support (this is required to connect to Salesforce).
-
A domain where WordPress is successfully running. For purposes of this documentation, we’ll assume that you are using
https://
. You would use
https://www.example.com
instead, if your site was
www.example.com
.
Activate the plugin
In the Plugins list in WordPress, activate the plugin and find the settings link (you can also find this plugin’s settings in the main Settings list in WordPress, under the Salesforce menu item once it is activated).
The plugin’s settings URL is
https://
/wp-admin/options-general.php?page=object-sync-salesforce-admin
.
Salesforce
Prerequisites
You’ll need to have access to a Salesforce developer account. This should come with Enterprise Edition, Unlimited Edition, or Performance Edition. Developers can register for a free Developer Edition account at
https://developer.salesforce.com/signup
.
We recommend using a Sandbox to set up this plugin first before running it in production.
For purposes of this documentation, we’ll assume that your name, as defined in Salesforce, is Your Name. This is what you see at the top right of the browser window, when you are logged in.
Create an App
-
In Salesforce, create a new Connected App. This differs between Lightning and Classic Salesforce.
-
Lightning:
Click on the cog icon at the top right of the browser window and click on
Setup
. Then on the left sidebar, under
App Setup
, click
Platform Tools >
Apps >
App Manager
. In the
Lightning Experience App Manager
section of this page, click
New Connected App
to create a new app.
-
Classic:
At the top right of the browser window, go to
Your Name >
Setup
. Then on the left sidebar, under
App Setup
, click
Create >
Apps
. In the
Connected Apps
section of this page, click New to create a new app.
-
Enable OAuth Settings
-
Set the callback URL to:
https://
/wp-admin/options-general.php?page=object-sync-salesforce-admin&tab=authorize
(must use HTTPS).
-
Select at least “Perform requests on your behalf at any time” for OAuth Scope as well as the appropriate other scopes for your application. Many setups will also need to select “Access and manage your data (api)” as one of these scopes.
Get the values for WordPress
After you save these settings, click Continue and you’ll see the values for your new app. For WordPress, you’ll need these values:
-
Consumer Key (in the screenshot, this value says “valuefromsalesforce”)
-
Consumer Secret (you’ll have to click “Click to reveal” to get this value)
Connect the plugin to Salesforce
Settings
Go to the Settings tab for the plugin. It is the default URL that opens when you click Salesforce in the main Settings menu. Enter the values based on your Salesforce environment.
-
Consumer Key: (your value from above)
-
Consumer Secret: (your value from above)
-
Callback URL:
https://
/wp-admin/options-general.php?page=object-sync-salesforce-admin&tab=authorize
-
Login Base URL: For most Salesforce environments, you can use
https://test.salesforce.com
for sandbox, and
https://login.salesforce.com
for production.
-
Authorize URL Path: The plugin starts with a default of
/services/oauth2/authorize
. You should generally not have to change this.
-
Token URL Path: The plugin starts with a default of
/services/oauth2/token
. You should generally not have to change this.
-
Salesforce API Version: You should generally use the latest version your install has access to. This plugin starts with 42.0, but once it is authenticated the text field will be replaced with a dropdown of your available versions from which you can choose.
-
Limit Salesforce Objects: These allow you to indicate whether Salesforce should relate to objects that can’t be triggered or updated via the API. Generally it’s a good idea to have these boxes checked to avoid errors.
-
Salesforce Field Display Value: When mapping Salesforce fields, you can choose whether the plugin will display a field’s Field Label (possibly a more user friendly value) or the API Name (which is always unique). Neither choice changes how the plugin functions on the back end, but making a choice can sometimes make the mapping choices easier to find.
-
Pull Throttle (seconds): This plugin starts with 5 seconds, but you can change it based on your server’s needs.
-
Debug mode: This won’t do anything until after the plugin has been authorized, but once it has you can use it to see more information about what the API is doing.
Don’t check this in a production environment.
Save the settings. If the values required are set, you’ll see a message that says “Salesforce needs to be authorized to connect to this website. Use the Authorize tab to connect.” You can use that link for the next steps.
Using constants for settings
You can set several of the above values as constants in your
wp-config.php
file. The plugin will always use a constant ahead of a database setting.
Supported constant names are:
-
OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY
-
OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET
-
OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL
-
OBJECT_SYNC_SF_SALESFORCE_LOGIN_BASE_URL
-
OBJECT_SYNC_SF_SALESFORCE_AUTHORIZE_URL_PATH
-
OBJECT_SYNC_SF_SALESFORCE_TOKEN_URL_PATH
-
OBJECT_SYNC_SF_SALESFORCE_API_VERSION
Set them in
wp-config.php
like this:
define('OBJECT_SYNC_SF_SALESFORCE_CONSUMER_KEY', 'valuefromsalesforce');
define('OBJECT_SYNC_SF_SALESFORCE_CONSUMER_SECRET', 'valuefromsalesforce');
define('OBJECT_SYNC_SF_SALESFORCE_CALLBACK_URL', 'https://
/wp-admin/options-general.php?page=object-sync-salesforce-admin&tab=authorize');
define('OBJECT_SYNC_SF_SALESFORCE_LOGIN_BASE_URL', 'https://test.salesforce.com');
define('OBJECT_SYNC_SF_SALESFORCE_API_VERSION', '40.0');
define('OBJECT_SYNC_SF_SALESFORCE_AUTHORIZE_URL_PATH', '/services/oauth2/authorize');
define('OBJECT_SYNC_SF_SALESFORCE_TOKEN_URL_PATH', '/services/oauth2/token');
For any value that is already defined in
wp-config.php
, the Settings screen will display “Defined in wp-config.php” in place of the text field.
Authorize
Go to the Authorize tab in the plugin’s settings. If it is not yet authorized, you’ll see a message that says “Salesforce needs to be authorized to connect to this website. Use the Authorize tab to connect.”
The authorize tab will force you to be logged in using HTTPS, if you weren’t already.
Steps:
-
Click the Connect to Salesforce button to authenticate WordPress with your Salesforce installation.
-
You may have to log into Salesforce.
-
Salesforce will ask you to allow access to the app (in these instructions, the name is WordPress Example), and will show you what permissions it needs.
-
Click Allow.
-
You’ll be redirected back to WordPress. Don’t do anything until you see a message that says “Salesforce is successfully authenticated.”
-
The tab will display a “Disconnect from Salesforce” button which you can click at any time, and will also show a bit of basic information about your Salesforce environment (the available API versions and a basic table of Contacts.)
-
If you’d like to use a different Salesforce API version, go back to the Settings tab and pick your desired version from the dropdown.
More documentation
There is extensive documentation of the plugin, including its developer hooks,
on GitHub
. You can find a detailed
initial setup instruction
document there as well.
|