check the user tidypics album for defining their role

Hi,

Could anyone point me the way to a solution to let elgg check how many images a user has with tidypics?
What I basicly want to do is to have a way to define a special role, let's call it 'empty_user' for anyone that has less then 5 images in their account.

I'm using the roles plugin and I would want to role to be set to the 'fedault_role' from the moment that they have more then 5 images in their account.

Thanks!

  • Nobody an idea on how to handle this the most easy way?

    I think this should be quite easy together with the roles plugin, probably with this function: function roles_set_role($role, $user = null)

    So, should this be in its own plugin, should it be part of tidypics, in the start file, should it be in the startfile of the roles plugin,...?
    I think it has to check whether the user has the 'empty_user' role or the 'default' role, and when the user has the 'empty_user' role, it has to check how many images there are in the users account, if it's + 5 it has to set this users role to 'normal'. Next time the plugin checks the users role and sees he has 'default' it can just move on and do nothing.

    Am I right here?

  • Too busy looking for TidyPics settings' code but the general code is:

                        $current_role = roles_get_role($user);
                        $current_role_name = $current_role->name;
                        if ($current_role_name == 'DEFAULT') {
                              HERE_IS_TIDYPICS_ACTION
                        }

    It's an action for TidyPics plugin or your own theme/plugin

  • Thanks RvR, though this isn't exactly what I intent to do, but usefull anyway, so thanks :)
    With this code I can check what someones role is and do an action.

    But I actually want to check what their image count in tidypics is and do an action according to that number, if it's under 5, I want their role to be set to 'novice' or something simmilar and do nothing if it's over 5.

  • Well, then additional to above code you need to set user' role as:

     

                        $current_role = roles_get_role($user);
                        $current_role_name = $current_role->name;

                        $new_role = 'PRO';
                        if ($current_role_name == 'DEFAULT') {
                              HERE_IS_TIDYPICS_ACTION
                        }

                       else if (HERE_IS_TIDYPICS_ACTION_VALUE && $current_role_name !== 'DEFAULT') {

                          roles_set_role($new_role, $user);

                      }

    I don't check it but think that all correct.

    Try it.

  • Hi RvR, sorry for the late reply, but..thank you! :)

Beginning Developers

Beginning Developers

This space is for newcomers, who wish to build a new plugin or to customize an existing one to their liking