Jump to content

IPS Rules Application


Recommended Posts

@icedream, download the latest version of the app. I've added some missing "content item viewed" event triggers which is why your rule was not being triggered.

Also, after taking a look at your rule, I noticed a few problems with your custom condition code:

  • In order to return a result from the database you need to use the first() method of the select object.  i.e. \IPS\Db::i()->select()->first()
  • Also, in the condition where you check the profile field for the member, you are using the "$member" variable, but that variable name is not included with the event, so you need to use \IPS\Member::loggedIn() instead.

I've made the appropriate changes to your rule for you:  check-adult-file.xml

Make sure you use at least version 1.0.8 of the Rules app for the event to be triggered. Also, I'm glad to see you're taking advantage of the custom PHP code fields! Good job!

Edited by Kevin Carwile
Link to comment

@icedream, download the latest version of the app. I've added some missing "content item viewed" event triggers which is why your rule was not being triggered.

Also, after taking a look at your rule, I noticed a few problems with your custom condition code:

  • In order to return a result from the database you need to use the first() method of the select object.  i.e. \IPS\Db::i()->select()->first()
  • Also, in the condition where you check the profile field for the member, you are using the "$member" variable, but that variable name is not included with the event, so you need to use \IPS\Member::loggedIn() instead.

I've made the appropriate changes to your rule for you:  check-adult-file.xml

Make sure you use at least version 1.0.8 of the Rules app for the event to be triggered. Also, I'm glad to see you're taking advantage of the custom PHP code fields! Good job!

​Brilliant Kevin, great Thanks.

Edited by icedream
Link to comment

Still having trouble making a value visible on the user end. Am I able to use the code below the header? I'm getting the following PHP error:

"Fatal error: Call to a member function getRulesData() on a non-object in /home/.../..."

​Collin, PM me for direct support on this.

But from the looks of it, you are trying to use a variable in your template that doesn't actually exist inside the template. For example, if you are trying to use $member->getRulesData( 'data_key' ), then the $member variable must be part of the template, otherwise you need to access a globally available variable such as \IPS\Member::loggedIn()->getRulesData( 'data_key' ).

 

Link to comment

​Collin, PM me for direct support on this.

But from the looks of it, you are trying to use a variable in your template that doesn't actually exist inside the template. For example, if you are trying to use $member->getRulesData( 'data_key' ), then the $member variable must be part of the template, otherwise you need to access a globally available variable such as \IPS\Member::loggedIn()->getRulesData( 'data_key' ).

 

​PM sent, thanks in advance. It may be that I'm using a variable that isn't allowed as you had mentioned (I tried to place it below the header). Thanks, and look forward to hearing from you soon.

Link to comment

Kevin - I downloaded and started playing with this the other day and I just have to say that this is probably the best mod/addon/plugin/application/whateveryouwanttocallit I have seen for IPB/IPS since I began using it 12 years ago. Cap well and truly doffed to you.

Could I get your input into a set of rules I'm thinking about?

I run a fan site for a football club and use the calendar for match fixtures. We also have a forum in which a topic exists for each match. Previously keeping both updated has been manual and I'd like to try to automate part of it.

When I create a fixture in the calendar, I'd like to create a topic in the forum with the same subject/title as the calendar item, but also include the start time & date of the calendar item. In addition, if/when the time/date of the calendar item changes then the subject of the topic is updated too.

Is this achievable with the application?

Link to comment

 @Nathan Explosion, totally achievable.

The first part of creating the topic for the calendar event with the appropriate title can be easily done with all stock rule ECA's + the calendar expansion pack.

The second part about keeping the topic title synchronized can also be done, but we'll likely have to write a couple more creative rules to get that done.

If you purchase the app, PM me with details for your site and we can work on it together.

Link to comment

Hi @Kevin Carwile

I would really like to see an expansion pack for Commerce, one where rules can be created based on;

  • product purchased
  • invoice status
  • account credit
  • transaction status
  • support ticket dept
  • support ticket status
  • support ticket severity
  • support note added
  • support reply added

That would really help us to link the purchase of a product, use rules to create a collaboration and create a support ticket to the member in order to help them set it up fully whilst being able to create an announcement on the forum and more. The options would be endless with this added to the excellent options already available.

Thanks

Link to comment

Yes, I agree fully. The commerce expansion has not been forgotten.

But it is going to be the largest expansion pack of them all as there is much more than what has already been listed for it to be a complete package.

First I need to get out a much smaller expansion to cover the core IPS downloads app, and then I will start on the ECA's for the commerce app.

And at some point in between all of this, I need to get some documentation written on how other developers can include their own ECA's in their apps using rules extensions in the developer center. My goal and hope is that all apps will be customizable with rules at some point.

Link to comment

Hi @Kevin Carwile

I am trying to create two rules but unfortunately I cannot get either to work the way I want and wonder if you could advise.

  1. The first rule is to create a topic when a member updates their profile photo (not their cover photo or any other field in their profile - just the photo) I cannot quite get it to acknowledge just the profile photo, it seems it creates a topic overtime anything is updated.
     
  2. The second one is to create a topic if a member of a particular group (our moderators) has had 'no activity' on the forum for the last 30 days to alert me to this fact from a security perspective. I can set this one up so far with a scheduled action to create the topic in 30 days if the member is of a particular group but what I cannot work out is how to then delete the thread from being created by deleting the scheduled action. It asks for a unique key and I have no idea how this is determined.

Any help with these two rules would be perfect.

Thank you

Link to comment

I'd be more than happy to help you out.

1. On the first rule, it sounds like you're using the correct event and have the action set up correctly, but you're having trouble with the condition portion of your rule.

  • Event: Member profile is updated
  • Condition: Check array value ( You want to check the array of profile fields that have changed for the "pp_main_photo" key )
  • Action: Create new topic

rule-when-member-photo-is-updated.xml

2. What you want to do in a situation like this is to create a custom action which you will use to create the topic. You will then schedule this custom action to happen in 30 days. That custom action then becomes a new event in the system that you can attach additional rules to so that you can check conditions when that action is invoked at the scheduled time, and take additional actions at that time such as either creating the topic if the member has indeed been inactive for the 30 days prior, or if not, rescheduling the custom action to happen again in another week or so which will repeat the process indefinitely.

As for the scheduling key portion of the equation, whenever you schedule an action, custom or not, you can enter a "scheduling key" for the action which will give it a unique identity so that you can operate on it later (such as delete it, or re-schedule it). When you use a scheduling key, you usually want to include a token of some sort from the event that will make it unique to a certain aspect of the event, such as the member id of the user it is being scheduled for. So the scheduling key for your use would look something like this:

create inactive topic for member:[member:member_id]

So when you schedule an action again with that same key, the old one is removed and only the new one remains (hence re-scheduling).

Link to comment

Hi @Kevin Carwile

Thanks once again  for the amazing support - its appreciated.

I have configured the rule for when members update their profile picture and it creates the topic. There is not a variable to link to the members profile that I can insert into the message. I have tried to build the URL as follows http://www.mysite.com/profile/member:id]-[member:name] however if i try using the variables in a url it does not convert them to the values. 

If I remove the hyperlink I can paste it as plain text which display fine and the variables are replaced but the link is not clickable. Any suggestions on how to do this please?

Thanks

Link to comment

In Pages, is it possible to limit the # of article/record submissions per user depending on which group they belong to?

  • ​Event: Output is being sent to browser
  • Conditions:
    • User is in a specific member group
    • Custom PHP Code (check if user is trying to add a new pages record):
      $page = \IPS\Request::i();
      $database_id = 1; // id of pages database
      return ( 
          $page->app          == 'cms' and 
          $page->module       == 'pages' and 
          $page->controller   == 'page' and
          $page->do           == 'form' and
          $page->d            == $database_id
      );
    • Custom PHP Code (check if user has already added a certain amount of records):
      $database_id = 1; // id of pages database
      $threshold = 10;
      $content_count = \IPS\Db::i()->select( 'COUNT(*)', 'cms_custom_database_' . $database_id, array( 'member_id=?', \IPS\Member::loggedIn()->member_id ) )->first();
      
      return $content_count >= $threshold;

       

  • Actions:
    • Redirect to another url (maybe another page that explains why they can't add more content
       

       

 

Link to comment

Hi @Kevin Carwile

The rule I am trying to configure is as follows;

If a secondary group of X is added to a member (the way this secondary group is added is via nexus product purchase) then this should change custom profile field Y to the value of Yes (True) its a simple profile field of Yes/No

Which ECA's should I tie in to for this to happen please?

Thanks

Link to comment

If a secondary group of X is added to a member (the way this secondary group is added is via nexus product purchase) then this should change custom profile field Y to the value of Yes (True) its a simple profile field of Yes/No

Which ECA's should I tie in to for this to happen please?

​I'm exploring options for including custom profile fields into rules ECA's, but at the moment, it is a very closed system and needs to be softened up by IPS a little bit for better 3rd party integrations.

What else are you using this custom Yes/No profile field for? You could create a custom Yes/No data field in rules and attach it to members and then you will have full rules access to check and update that field. In which case you would have a rule that looks like this:

  • Event: Member profile is updated
  • Conditions:
    • Member is in a certain member group
    • Truth value (check the Yes/No custom field for user)
  • Action: Update custom data for Yes/No field
Link to comment

Hi @Kevin Carwile 

We are effectively using custom profile fields to display additional badges on a members profile card next to their posts in threads. So if a member verifies their identity they get access to additional areas of our site, in doing that we adda  secondary group to their account which controls the access. We then manually toggle the custom profile field to on which displays a verified member badge on their profile card next to new posts.

Link to comment

Hi @Kevin Carwile

Here is one to see if it's possible as I cant work it out :lol:   

Like you did with the Move to any Forum ID option to integrate collaborations, is it possible to have another field on a thread that is administrative that allows the directory to be searched for members so you can enter multiple members names that would re-direct those users from being able to view that specific thread to a custom URL? 

  • So user A has been a royal pain in the but and we want to thread ban him from this specific thread.
  • We go to the first post in the thread, hit edit and an administrative field appears to enter member display names.
  • We then save that amendment. 
  • When that user tries to view that thread moving forward they are re-directed to a custom URL (Which I will create to display a banned message to them in pages) 
  • If their name gets removed from that field then they are able to view that thread again

Many Thanks

 

Link to comment

Like you did with the Move to any Forum ID option to integrate collaborations, is it possible to have another field on a thread that is administrative that allows the directory to be searched for members so you can enter multiple members names that would re-direct those users from being able to view that specific thread to a custom URL? 

​Currently, rules only includes form fields to edit integers, text fields, and yes/no switches. I will be expanding the available form options to include node selectors, member selectors, and editors. When that is complete, you will be able to accomplish your goal as you had mentioned using rules.

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...