12

Using Config files

Thumbnail for Using Config files

If you use plugin on standard WordPress installation, and you don’t need advanced access control for the plugin, you can safely skip this tutorial. If your wp-content is moved or you are user of WordPress MU I strongly recommend reading this.

Plugin settings are mostly controlled by the specialized panel. But, for some things we still need a file with some of the settings. Plugin actually has 2 config files. Main one is config.php, and I don’t recommend modifying it because afetr each upgrade this file will be reseted to defaults. But, the other file gdsr-config.php is the one we want. All changes we need go into this file.

Before we go any further: All this requires GD Star Rating 1.6.1 or newer.

First you need to move gdsr-config.php from wp-content/plugin/gd-star-rating into parent folder: wp-content/plugins. If this file is not there, it will not be used. So, once you copy this file, you can than modify it (modify copied file, not original). This file contains several global constants.

WP-Content moved outside WordPress

WordPress allows that you move wp-content folder outside of the WordPress folder. When this happens, plugins AJAX features will have problem finding WordPress. In that case, you need to tell plugin where WordPress is. For this you need to set STARRATING_WPLOAD variable to exact path of WordPress wp-load.php file. So, you need to open gdsr-config.php file, and on line 8 you need to set this:

Example: define(‘STARRATING_WPLOAD’, ‘full/path/to/wp-load.php’);

Setting basic access levels

This is mostly for WPMU users, but anyone can use this. There are several global variables used for this. And all of them are again in gdsr-config.php file.

  • STARRATING_ACCESS_LEVEL: this is main constant, and panels visibility depends on this, and only users with level the same or higher as defined in this variable will be able to access all plugins panels. Default is 9, and this will include all administrator accounts. Setting this to 10, will allow only main admin account to control the plugin.
  • STARRATING_ACCESS_LEVEL_BUILDER: users with level set here will be able to use Builder panel. Default is set to 1, and contributors can use the Builder.
  • STARRATING_ACCESS_LEVEL_SETUP: users will level higher than this one will see Setup panel. In the same time they need to be at least level set with STARRATING_ACCESS_LEVEL. So, you can allow all admins to use plugin (with STARRATING_ACCESS_LEVEL set to 9), but you can allow only main admin to use Setup panel (with STARRATING_ACCESS_LEVEL_SETUP set to 10).

Next step for WPMU users will be to control where the settings are stored and used for sitewide limitations, and once I complete that, I will add more ways of controling that.

Fall back to defaults

If you have problems with all this, simply delete gdsr-config.php file from wp-content/plugins folder.

GD Star Rating
loading...
Using Config files8.01060

Share this:

RSS DiGG Google Buzz Google Technorati StumbleUpon Design Float Microsoft Live PDF Favorites

12 Responses to “Using Config files”

  1. Dan

    August 12, 2009
    at 5:46 PM

    MillaN, I’ve changed all the user levels to 10 in gdsr-config.php and set the admin user ID to my ID, but the blog admins can still see and access every panel.

    I don’t see how this works anyway, aren’t the people who have blogs in an WPMU environment given level 10 status anyway. Surely something more is needed to prevent them from seeing the panels?

    Thanks.

    GD Star Rating
    loading...
    • MillaN

      August 12, 2009
      at 6:04 PM

      Try 1.6.1_rev1 version and tell me if the problems are gone now. You can get it from Plugin Download page here.

      GD Star Rating
      loading...
  2. Dan

    August 12, 2009
    at 6:50 PM

    The security panel option works, only I as user_ID 1 can see it – although there is nothing on the security page.

    However, blog owners can still see all panel options. Maybe if would be easier if you also provided the option to hide all panels based on user_ID as well.

    GD Star Rating
    loading...
  3. MillaN

    August 12, 2009
    at 7:02 PM

    So, now with rev1, things are OK? As for the user ID, this is next in line for better WPMU centralized control, but that will need much more work.

    GD Star Rating
    loading...
  4. Dan

    August 12, 2009
    at 7:05 PM

    No it is not working. Blog owners can still see and access all panels with the rev1 update. The only thing that works is that the security panel is hidden from them. My point is the user_ID security is working but the user_level security does not seem to be working.

    GD Star Rating
    loading...
    • MillaN

      August 12, 2009
      at 7:12 PM

      And you copied gdsr-config.php outside of gd-star-rating folder? Can you confirm this, and tell me how you set this file?

      GD Star Rating
      loading...
      • Dan

        August 12, 2009
        at 7:25 PM

        Yes, I copied gdsr-config.php to wp-content/plugins. I set all access levels to 10.

        GD Star Rating
        loading...
        • MillaN

          August 12, 2009
          at 7:28 PM

          Well, something is definitely strange with WPMU. I will investigate more.

          GD Star Rating
          loading...
        • MillaN

          August 12, 2009
          at 8:18 PM

          What version of WPMU you are using? I have tested only with WPMU 2.8.2 and higher, and I will not going to support older versions. On my WPMU setup, everything works fine with rev1, regular users don’t see menus that they shouldn’t see.

          GD Star Rating
          loading...
          • Dan

            August 12, 2009
            at 8:47 PM

            I am using the latest version of WPMU 2.8.4.

            I think the problem may lie in what we define as users. I want the GD Star panel links hidden from everyone, this includes admins of blogs, except me – the site owner.

            I think blog admins have level 10 access on their own blogs, so this is why they can still access the GD Star options.

            Another type of access restriction might be needed. As I said previously the is_site_admin tag does this job. It only gives access to the site owner, anyone else even with level 10 access is restricted.

            GD Star Rating
            loading...
          • MillaN

            August 12, 2009
            at 9:17 PM

            Yes, WPMU has much different users structure. As I said, I will need much more time to solve all WPMU related issues.

            GD Star Rating
            loading...
  5. Dan

    August 12, 2009
    at 7:07 PM

    I should explain by panel I mean links.

    GD Star Rating
    loading...

Comments are closed.

Social Networks

Subscribe via Feedburner Flickr Images

Feedburner updatesFeedburner

Sign up to receive all latest news about GD Star Rating directly to your email.