Hi,
I am hoping that someone can help me. I am digging around in the rule creation window; I have already created a bunch of rules to create add and remove user points.
I am having a problem with using Rules to add user points to a referrer. I have created a text field where a new user who is registering can enter the username of the individual who referred them to the site. The goal is to award a certain number of user points to the referrer on sign up.
I also plan to create a variety of rules to promote and demote users' assigned role based on their user points (there is a reason for me adding all of these roles, I can get into it if you want but in a nutshell i want the ability to play with permissions for each role), and to award user points to the referrer when the referee acheives a certain number of user points as well.
Where I am at a complete loss is how to get the workflow to do something like this
Rule Test > When a new user is saved > data comparison > if user_referrer equals a valid username > award that username points.
I can find all sorts of direct hits in the data selector, but I can't seem to find any way to make rules scan the user name table and match a hit of a particular username, and do nothing if there is no match or the field is blank.
I have skimmed as much documentation as I could find, but nothing seems to address this question. Sorry if it's out there smacking me in the face. This is important to me as I will probably be creating 50-60 different rules based on this technique.
Thanks for any help you can provide! :-)
Comments
I found a referrer module,
I found a referrer module, I'm not sure if I want to use it. I'd rather just use rules straight up to make the associations if possible. However if I need to install the module to populate a field like user:referrer I guess thats what I'll have to do. However there must be a way to do a data compare or text compare in rules to do what I'm looking for.
User Points module
Have you looked at the user points module? http://drupal.org/project/userpoints
It appears that through the User Points contrib modules, http://drupal.org/project/userpoints_contrib, there is one userpoints_invite - Users earn points when they invite other, and when others register, that would accomplish what you're trying to do.
I'll take a look... however I
I'll take a look... however I am really trying to find a way for Rules to determine a referrer or username in a field because with all of these parameters it will at the very least, come in very handy
userpoints_contrib
It does look interesting, I like the ability to add points when the user "invites" other people to join the site, and then how it adds points if they actually do join the site. However I dont know if it will give me the ability to give the referrer positive or negative point adjustments later on down the road. I am already using userpoints and I am using Rules to add and remove points on a variety of actions.
One problem with the userpoints_invite though is the requirement that the referring user pass along an e-mail or a specific link to the referee; requiring them to click on a specific link or on a link on the profile page of the referrer in order to become a referee of the referrer. A lot of our marketing is word of mouth and done by aliases, or by handing out business cards physically at some remote location in the forest. The more complicated the registration process is the more likely that admins will be requested to "fix" broken referee links later.
Which I guess gets me back to my original question.
Is there any way that Rules can do a text or data comparison on a particular field to match a username in a field in the user's profile to a user that is registered on the site? Most of the fields I see are related to the current user, sitewide or node. I would really like to avoid any custom hardcode as that will only make upgrading a serious PIA later; same goes for installing lots of modules. I'm on D7 and I've been amazed at how long it has taken for some major modules to be ported to D7 while the core of D8 has been released already. The more modules I count on the more variables for upgrade paths I am married to.
If I stick to using Rules as much as possible in leui of five or ten different modules; I should be able to get the granularity I want and simply follow the upgrade path for Rules.
ok I have dug in head first
ok I have dug in head first and have ended up right back where I started. Userpoints contributed modules is a mess. The dev team and contributors are absent for over a year, after my experience with userpoints_role I am really loathe to even contemplate taking a stab at the integration of Invite and userpoints through userpoints_invite. The software gives no errors and does precisely the opposite of what it`s supposed to do. Userpoints_role happily gives all related roles regardless of points score on the awarding of a single point.
I found a workaround in there somewhere implementing PHP Code using Rules along with some rather fantastic options which do not seem to be at all available in my rules installation. I havent tried using the workaround yet; as there were some debates over the use of tokens or mashing it to create a container variable that Rules can use in it`s arguments.
These options like èxecute PHP script etc. I dont see them like the people who have created this workaround do. I in theory have the latest stable version of Rules as I just recently went through an updating nightmare to try to get these contributed modules working.
It all comes back to two things...
a) How can you implement rules to do a data comparison like:
if userpoints is equal to or greater than 100 (arbitrary number) then execute the following action(s)
and
b) To do a text or UID search to do a comparison like
If referrername matches a registered user, then award that registered user points
secondarily to do specifically with Roles...
c) add and remove roles from an account like,
if userpoints is greater than 100 but less than 200 then remove all roles and add role number 1 to the user
--
I really wish I was a better coder... Then maybe I would fix the userpoints contributed modules that I need and give the legions of people crying for help over there some reason to cheer.
PHP filter
I am sorry to hear that the Userpoints module feels abandoned. I can't give all the answers you need, but hopefully something get going again.
It seems that you are looking for the PHP filter module, that allows you to add PHP code in your Rules configuration. With that, you can manipulate objects sent in to the rule, and also call functions available to Drupal in general. The PHP filter module is available in core, so no new download is necessary. (I should warn you though, most developers find PHP filter a slow, ugly and insecure solution…)
If you want to get some basic PHP coding skills, you can try watching this screencast series I made some time ago: http://dev.nodeone.se/en/learn-drupal-coding-with-nodeone
The series is recorded for Drupal 7, which means that not everything works for D6, but most things should be very similar.
Good luck,
//Johan Falk
**
Check out NodeOne's Drupal Learning Library! 250+ screencasts and exercises, for Drupal introduction, advanced configuration, and coding. Creative Commons license!