Aug 29, 2021

Grow your WordPress business by acquiring the Amazon Alexa skill users

So, you have interesting content on your website that could be translated into a very voice application – e.g. Alexa skill. In this case you are able to approach the whole new bunch of users, with common characteristics of smart speakers/displays usage. By enabling account linking, you are able to import those users into your WordPress and make them into subscribers, users, leads … It is good to know that our WP Insert User Element uses the WordPress wp_insert_user() function, meaning that all required filters will be triggered and you can do additional things in your theme or plugin.

If you haven’t so far, check the Account Linking blog post, where you will learn how to set up account linking with Amazon.

Basic Usage Example of the WP Insert User Element

As we mentioned, WP Insert User Element internally uses the WP function wp_insert_user(array|object|WP_User $userdata), which creates or updates an user on WordPress. For more info on how the function works, check out the WordPress Code Reference.

Like many other Convoworks elements, Init Amazon User Element has a set of properties, where you can specify what data to use and it has several sub-flows, which will trigger based on the execution result. In this element we have three sub-flows (or scenarios): On Success, On Failure and On User Exists.

The result or additional info about operation is available as a request scope variable, by default created_user. Depending on the sub-flow, it will contain different sub members.

On Success

The On Success execution flow is executed when the user was inserted in your WordPress site. This flow will only execute when the user with the provided username doesn’t exists.

In this case your created WP_User is available like this ${created_user.user}. Here are few examples:

  • ${created_user.user.ID}
  • ${created_user.user.data.user_login}
  • ${created_user.user.data.user_email}

On Failure

The On Failure flow is executed when the user couldn’t be inserted in your WordPress site. This will typically fail if you forget to provide an username to the Username property to the WP Insert User Element.

In this case your result contains WP_Error object and you can access it like this ${created_user.wpError}.

On User Exists

The On User Exists execution flow is executed when the user already exists in your WordPress site. As in the On Success flow, you will have access to the WP_User object in a familiar way ${created_user.user}.

 

Element Properties

The configuration process for this element is very easy. The only thing you really have to provide is username and valid email address for the new user.

This element is only able to insert new users with the following fields:

  • Name – name under which to store the recently created user, so that you can access either the WP_User or WP_Errror object
  • Username – this field is required, otherwise you’ll get an WP_Errror
  • Email – this field is optional, but recommended for the user to be able to reset its password
  • Role – this field is optional, but if you leave it blank when using a custom role, WordPress will instead fill the default role from its options, otherwise you can select an role from your WordPress installation
  • WP User meta input – if you want to add some specific meta for the users created via your Convoworks service

That’s it, for the configuration of the element. Now you can use this WP_User and retrieve the posts for the user or whatever you want to do.

 

Conclusion

As you can see, from the technical point of view, creating a user through Alexa skill is a quite easy and straightforward task. The way how it should be on WordPress.
Just don’t forget that in order to attract users, you have to create useful and engaging Alexa Skill. Check your services and figure out what piece of information you have and it would be very useful to be accessed by voice and start creating your Alexa skills today!

Mark Marčec

Mark Marčec

Aug 29, 2021  | 

Know your users with Alexa Account Linking (with PHP and WordPress)

Account linking enables your voice application to access user information during its execution. That way you can know your…

VIEW FULL POST

Apr 1, 2021  | 

Build your own Audio Player or Sounds Skill with Amazon Alexa and WordPress website

Interested in developing your own Alexa sounds skill? Your new shiny Alexa sounds skill can be ready in a…

VIEW FULL POST