1. Home
  2. Docs
  3. How to
  4. How to Create Salesforce Contact Records on WordPress User creation

How to Create Salesforce Contact Records on WordPress User creation

This article explains how you can create records on Salesforce automatically when users are created on WordPress.

If you’re looking to create WordPress logins when new Salesforce records are created, check this instead:

Are you setting up a Salesforce-WordPress portal for your site?

You can use the Sawfish plugin to create unlimited number of logins through WordPress by connecting them to Contact or other objects on Salesforce. The plugin will automatically match them to their record on Salesforce when your users login to your WordPress website.

This means your users can securely login and manage their info without your team having to buy additional licenses or do manual data updates. You can check out more details of this feature below:

Great, this works well for connecting and setting up logins for existing users. But what about adding new users? Your new WordPress sign ups will also need Salesforce records created with their details when they register on your site.

How do you create Salesforce records from WordPress? (when a new user is created)

You can create user records on Salesforce by integrating the WordPress user creation function with Salesforce. This would automatically create Salesforce records when users register on your Website. The Sawfish plugin does the heavy Salesforce-WordPress integration work for you so you can easily setup this automation.

For Easier Setup

You can use our free extension to the Sawfish Plugin to setup the function without any code. Just send us a quick email to for the download link!

You can use our extension for a quicker setup or you can use the advanced option below with the custom code

For Advanced Users

You can use the code snippet below to create Contact records on Salesforce when new logins are created on WordPress. The wp2sforce in the plugin connects with the user_register action. This runs both when WordPress users are created from the dashboard or by the users themselves through a registration form.

You can then update additional information on Salesforce and enable users to login and retrieve their information from fields and related records like Cases and Opportunities. This flow can be used to setup as many logins as you like!

Need help setting it up? Just send us a quick email and we’ll set up this feature for your site in minutes! No extra charges. 🙂

add_action( 'user_register', function ( $user_id ) {
 
	$user_info = get_userdata( $user_id );
 
	$first_name = $user_info->first_name;
	$last_name = $user_info->last_name;
	$email = $user_info->user_email;
 
	$fields = json_encode( array(
			'FirstName' => $first_name,
			'LastName' => $last_name,
			'Email' => $email,
		));
 
	$shortcode = "[wp2sforce o='Contact' content='".$fields."' type='create']";
 
	do_shortcode( $shortcode );
 
} );

Was this article helpful to you? Yes No