# Wordpress Plugin what does it do?

**URL:** <https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606>\
**Category:** Product Support\
**Created:** [October 23, 2015, 8:10pm UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606 "2015-10-23T20:10:06Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![healthstatus](https://avatars.discourse-cdn.com/v4/letter/h/9f8e36/32.png) [@healthstatus](https://forum.mautic.org/u/healthstatus)\
**Post date:** [October 23, 2015, 8:10pm UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/1 "2015-10-23T20:10:06Z")

</div>

I have the wordpress plugin on my site, but after some investigation, if an existing user logs in, their lead information is not updated. When users register, it does not appear that their lead is converted from anonymous to a known lead and updated with their name or information either. It seems to me that is what the plugin should be doing, taking information that happens in wordpress and moving it into the Mautic system. Am I missing something?

---

<div class="post-metadata">

**Author:** ![healthstatus](https://avatars.discourse-cdn.com/v4/letter/h/9f8e36/32.png) [@healthstatus](https://forum.mautic.org/u/healthstatus)\
**Post date:** [October 23, 2015, 8:10pm UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/2 "2015-10-23T20:10:06Z")

</div>

I have the wordpress plugin on my site, but after some investigation, if an existing user logs in, their lead information is not updated. When users register, it does not appear that their lead is converted from anonymous to a known lead and updated with their name or information either. It seems to me that is what the plugin should be doing, taking information that happens in wordpress and moving it into the Mautic system. Am I missing something?

---

<div class="post-metadata">

**Author:** ![ninjoan](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ninjoan/32/1005_2.png) [@ninjoan](https://forum.mautic.org/u/ninjoan)\
**Post date:** [October 26, 2015, 2:16am UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/3 "2015-10-26T02:16:45Z")

</div>

Wordpress plug in work only showing the Mautic Form. (integrate the form in you WP Website)

---

<div class="post-metadata">

**Author:** ![derrickm](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/derrickm/32/31_2.png) [@derrickm](https://forum.mautic.org/u/derrickm)\
**Post date:** [October 26, 2015, 3:53am UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/4 "2015-10-26T03:53:13Z")

</div>

If you look at the plugin directory entry for WP Mautic ([https://wordpress.org/plugins/wp-mautic/](https://wordpress.org/plugins/wp-mautic/)), you’ll see that the plugin does three things:

1. It inserts the Mautic tracking image on every page of your Wordpress site.

2. It adds extra information to the tracking data, e.g. the title and URL of the page.

3. It allows you to use a shortcode to insert a Mautic form into a page.

If you want to automatically add new Wordpress users to Mautic, you’ll need to work out a way to integrate Wordpress signups with Mautic.

---

<div class="post-metadata">

**Author:** ![healthstatus](https://avatars.discourse-cdn.com/v4/letter/h/9f8e36/32.png) [@healthstatus](https://forum.mautic.org/u/healthstatus)\
**Post date:** [October 26, 2015, 8:33pm UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/5 "2015-10-26T20:33:10Z")

</div>

OK, this seems to be shortsighted to have user information but not pass it to the automated lead management system, so I have made these changes to the wpmautic.php file of the Wordpress plugin. First go to your Mautic Dashboard, manage lists, edit the email, firstname, lastname fields and change them to be publicly updatable. I then added two fields, wp\_user & hsbloguser (alias must match these or you must adjust the code), as text fields and made them publicly updateable as well.

here are the changes: in the wpmautic\_function, after line 53 I added this:

```auto
        $user_query = wpmautic_get_user_query();
	foreach($user_query as $key => $val){
		$url_query[$key]=$val;
		}
```

and at the bottom after the existing } I added a new function:

```auto
/**
 * Adds the user email, and other known elements about the user.
 *
 * @return array
 */
function wpmautic_get_user_query()
{
	global $wp;
	$attrs = array();

	if ( is_user_logged_in() ){
		$current_user = wp_get_current_user();
		$attrs['email'] = $current_user->user_email;
		$attrs['firstname'] = $current_user->user_firstname;
		$attrs['lastname'] = $current_user->user_lastname;
// I added these as fields to my list the alias for the fields must match these names (or adjust accordingly)
		$attrs['wp_user'] = $current_user->user_login;
		$attrs['hsbloguser'] = $current_user->display_name;
		return $attrs;
		}
	else{
		return null;
		}

}
```

Basically, if the user is logged into wordpress, we grab what we know about them and return to be encoded with the URL and Title and pass it to Mautic, if they are not logged in, we do nothing, and the URL and Title are encoded as before.

I don’t do GIT so if someone wants to handle that it would be appreciated.

---

<div class="post-metadata">

**Author:** ![Svet\_Zitrka](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@Svet\_Zitrka](https://forum.mautic.org/u/Svet_Zitrka)\
**Post date:** [January 26, 2016, 8:38am UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/6 "2016-01-26T08:38:27Z")

</div>

Hello,  
you have any further extensions for WordPress, it would be a great asset for us.  
Any idea why everything preparations were not entered into the official plugin?

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [January 27, 2016, 7:55am UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/7 "2016-01-27T07:55:30Z")

</div>

I’ve created a pull request with the code from above comment. Please, test it:

[https://github.com/mautic/mautic-wordpress/pull/18](https://github.com/mautic/mautic-wordpress/pull/18)

---

<div class="post-metadata">

**Author:** ![Svet\_Zitrka](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@Svet\_Zitrka](https://forum.mautic.org/u/Svet_Zitrka)\
**Post date:** [January 27, 2016, 10:07am UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/8 "2016-01-27T10:07:00Z")

</div>

Thanks for sharing.  
Tested 2x but unfortunately it seems inoperative see. screen. Mautic runs on your own hosting  
[link image](https://drive.google.com/file/d/0B1b90NDTaPtgb1czdlN1RXFCa0U/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![escopecz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/escopecz/32/370_2.png) [@escopecz](https://forum.mautic.org/u/escopecz)\
**Post date:** [January 28, 2016, 12:04pm UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/9 "2016-01-28T12:04:19Z")

</div>

Do you have the plugin’s Base Mautic URL configured correctly? Do you test it without the Mautic session as described at [https://www.mautic.org/docs/pages/troubleshooting.html](https://www.mautic.org/docs/pages/troubleshooting.html) ?

---

<div class="post-metadata">

**Author:** ![Svet\_Zitrka](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@Svet\_Zitrka](https://forum.mautic.org/u/Svet_Zitrka)\
**Post date:** [January 28, 2016, 9:40pm UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/10 "2016-01-28T21:40:45Z")

</div>

Basic setting is correct but even so expansion is not working. Tested to someone else  
Can you think of where he might be the problem?

---

<div class="post-metadata">

**Author:** ![Dataline](https://avatars.discourse-cdn.com/v4/letter/d/d26b3c/32.png) [@Dataline](https://forum.mautic.org/u/Dataline)\
**Post date:** [January 29, 2016, 11:18am UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/11 "2016-01-29T11:18:11Z")

</div>

I’ve tested it also, the problem is that is\_user\_logged\_in() returns false for some reason. I’m looking into it …

---

<div class="post-metadata">

**Author:** ![Dataline](https://avatars.discourse-cdn.com/v4/letter/d/d26b3c/32.png) [@Dataline](https://forum.mautic.org/u/Dataline)\
**Post date:** [January 29, 2016, 1:05pm UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/12 "2016-01-29T13:05:52Z")

</div>

i’ve reworked the code so that it creates the correct tracking pixel code. However fields are not getting updated. I’m running 1.2.4 and fields are set to publicly updateable. Even if I hard code a field it doesn’t update. It works, had to clear my cookies first, I was probably recognised as a mautic admin when I tested.

Anyways here’s the code for the wp plugin to generate tracking pixel with user parameters:

add this after `add_action('wp_footer', 'wpmautic_function');` :

`add_action('init', 'getuser');
function getuser(){
	global $current_user;
	get_currentuserinfo();
}`

this is an updated version of the wpmautic\_get\_url\_query function:

[code]function wpmautic\_get\_url\_query()  
{  
global $wp;  
global $current\_user;

```
$current_url = add_query_arg( $wp->query_string, '', home_url( $wp->request ) );

$attrs = array();
$attrs['title'] = wpmautic_wp_title();
$attrs['language'] = get_locale();
$attrs['referrer'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : $current_url;
$attrs['url'] = $current_url;

if ( is_user_logged_in() ){
	$attrs['email'] = $current_user->user_email;
	$attrs['firstname'] = $current_user->user_firstname;
	$attrs['lastname'] = $current_user->user_lastname;
} 

return $attrs;

```

}[/code]

---

<div class="post-metadata">

**Author:** ![Svet\_Zitrka](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@Svet\_Zitrka](https://forum.mautic.org/u/Svet_Zitrka)\
**Post date:** [January 29, 2016, 4:16pm UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/13 "2016-01-29T16:16:36Z")

</div>

Cache deletion, but it does not  
You can share the entire modified plug a’t I’m confident that we made a mistake somewhere?

---

<div class="post-metadata">

**Author:** ![Dataline](https://avatars.discourse-cdn.com/v4/letter/d/d26b3c/32.png) [@Dataline](https://forum.mautic.org/u/Dataline)\
**Post date:** [January 29, 2016, 6:23pm UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/14 "2016-01-29T18:23:32Z")

</div>

[this](https://www.dropbox.com/s/dnt3zsmw06ujkle/mautic-wordpress-master.zip?dl=0) is the updated plugin. It works for me. Self hosted Mautic 1.2.4 and wordpress 4.4.1.

---

<div class="post-metadata">

**Author:** ![Svet\_Zitrka](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@Svet\_Zitrka](https://forum.mautic.org/u/Svet_Zitrka)\
**Post date:** [January 29, 2016, 8:20pm UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/15 "2016-01-29T20:20:39Z")

</div>

Thanks for the files. Woocommerce delight.  
But even so, I’m working. WordPress seems that everything is gone, but mautic accepted. Can you direct me to solve the problem? I set everything according to instructions, [see. picture](https://drive.google.com/a/svetandroida.cz/file/d/0B4O5BbenG6KRQlRKQ3ZNdW9NSHc/view?usp=sharing)

---

<div class="post-metadata">

**Author:** ![Svet\_Zitrka](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@Svet\_Zitrka](https://forum.mautic.org/u/Svet_Zitrka)\
**Post date:** [January 31, 2016, 10:00am UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/16 "2016-01-31T10:00:39Z")

</div>

So finally my works. Big thanks for the help @escopecz. Enough to completely delete the cache and everything works. It seems that Cache is a common problem of errors in Mauticu

---

<div class="post-metadata">

**Author:** ![mfuller](https://avatars.discourse-cdn.com/v4/letter/m/f14d63/32.png) [@mfuller](https://forum.mautic.org/u/mfuller)\
**Post date:** [April 29, 2016, 1:01am UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/17 "2016-04-29T01:01:11Z")

</div>

Dateline,

The link you provided on Jan 29th, to the update plugin, no longer works. Could you provide an updated link?

Thanks greatly.

---

<div class="post-metadata">

**Author:** ![jono](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jono](https://forum.mautic.org/u/jono)\
**Post date:** [July 15, 2016, 1:40pm UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/18 "2016-07-15T13:40:11Z")

</div>

Hi,

From this post it looks like mautic might be able to do what I need it to.

1.)  
a.) Does any one know if its possible to automatically add wordpress users to a mautic email campaign automatically (without having to enter a mautic form) when they create a new wordpress account?

b.) When a user creates a Wordpress account can mautic automatically add them to a Mautic email campaign? Or does the user have to first opt-in to a mautic form? For example can you automatically put all new wordpress user sign ups into a campaign called “Welcome emails series autoresponder”?

2.) Can mautic sync wordpress users information, for example when a user updates there name, email etc… in their Wordpress user account it sync this info to mautic?

[quote]escopecz Jan 27 Administrator  
I’ve created a pull request with the code from above comment. Please, test it:

[https://github.com/mautic/mautic-wordpress/pull/18[/quote]](https://github.com/mautic/mautic-wordpress/pull/18%5B/quote%5D)

With reference to escopecz post above, I downloaded the new version of the Mautic-WP plugin but I can’t seem to find the settings were I need to Configure Mautic Lead Fields, create username, HS blog name fields etc… as described in the readme

3.) Does any one have any tutorials or know were in Mautic I can find this? (Sorry I’m not very technical)

Thanks 🙂

---

<div class="post-metadata">

**Author:** ![jono](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jono](https://forum.mautic.org/u/jono)\
**Post date:** [July 19, 2016, 1:12pm UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/19 "2016-07-19T13:12:03Z")

</div>

Hey,

I got it working,

When I sign up for a Wordpress account mautic auto adds the users details to the contacts list.

When I update the wordpress user email for the first time it also updates on mautic. However when I update the email in WP for a 2nd time it does not update the new user info in mautic any more.

1.) Is it only supposed to sync once?  
2.) Is Mautic meant to sync Wordpress users details?

In the Custom Fields I’ve tried Unique Identifier on/off for email and wp\_user.

I also have, First Name, Last Name, Email, hsbloguser, wp\_user and Title fields.

3.) Any Ideas?

Cheers

---

<div class="post-metadata">

**Author:** ![jono](https://avatars.discourse-cdn.com/v4/letter/j/7ab992/32.png) [@jono](https://forum.mautic.org/u/jono)\
**Post date:** [July 20, 2016, 3:16am UTC](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606/20 "2016-07-20T03:16:33Z")

</div>

Hey,

Looking for some advice.

I’ve set this up, when a user creates a wordpress account it syncs their contact info into Mautic and adds them as a contact/lead, which is good 🙂

The problem I’m having is that when a 2nd user signs up using the same IP (with a different email, cleared cookies and new browser) Mautic does NOT create a new contact/lead, instead it updates the first contact/leads info ☹

Obviously this is bad for those using public internet, E.g schools, shopping malls etc…  
1.) Is it possible to set it so that Mautic creates a new lead regardless of IP address?

NOTES:  
I’ve tried setting Custom Fields Email Unique Identifier YES/NO and wp\_user Unique Identifier YES/NO. I though the wp\_user would work because wordpress users can not change their user name but unfortunately it didn’t seem to solve the issue.

Also I know that when using form you can avoid this my setting it to Kiosk however this doesn’t seem to be an option as this is not a form.

Thanks

[Next page](https://forum.mautic.org/t/wordpress-plugin-what-does-it-do/2606.md?page=2)
