Mautic Community Forums

Wordpress Plugin what does it do?

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?

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?

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

If you look at the plugin directory entry for 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.

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:

        $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:

/**
 * 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.

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?

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

https://github.com/mautic/mautic-wordpress/pull/18

Thanks for sharing.
Tested 2x but unfortunately it seems inoperative see. screen. Mautic runs on your own hosting
link image

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 ?

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?

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

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]

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

this is the updated plugin. It works for me. Self hosted Mautic 1.2.4 and wordpress 4.4.1.

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

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

Dateline,

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

Thanks greatly.

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]

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 :slight_smile:

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

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 :slight_smile:

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 :frowning:

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