Give user free/trial visibility package on registration

After a few request from clients, I have come up with a method that you can automagically give a user a package when they register on your site, which can be used as a way to provide a “free trial” or “free” package initially.  This does require adding some PHP code to your child theme’s functions.php file (or using the Code Snippets plugin).

I have been looking at different ways to integrate this into the plugin for a future update, probably when creating a new visibility package you can select a checkbox that says something like “Hide from cart, and assign to new users on registration”, but if you would like this functionality before I can release this update, here’s some example code to do this:

You will notice there are two actions, one for Job and one for Resumes … if you only need this for Job packages, or only for Resume packages, you can omit the add_action and the associated function (do not omit the function to check user roles).  As an example, if you only needed this for Job Packages, you would use this code instead:

You will also notice in the code that there is a check for the User Role before assigning a package.  You can change this to any specific user role you want, but in these examples the user role of employer is used for Job Visibility packages, and candidate for Resume Visibility Packages.

Total 0 Votes

Tell us how can we improve this post?

+ = Verify Human or Spambot ?