WordPress.org

Ready to get started?Download WordPress

Forums

category-visibility when using multiple installs in 1 database (7 posts)

  1. drobbins
    Member
    Posted 9 years ago #

    Hi - I searched around to see if someone had asked this before, with no luck, so hopefully this isn't a waste of time and space ... Anyway, my question/problem is with the category-visibility plug-in, which I have been trying to use; however, I keep running into bugs. The good news is that I think I know what the problem is, (BIG disclaimer here that I may be very very wrong indeed) - BUT, I've no idea how to fix it - and I was hoping one the many gifted PHP sages might help me out.
    Anyway, the problem, I think, is happening because the category-visibility plugin doesn't add the pre-defined table prefix that can be set during the installation process ... it instead just creates the table "category visibility," with no wp_ or whatever it is set for. That is all good and fine, unless you are using multiple installs in one database, like I am - and I think that is where I am getting the problems. SO - if it isn't obvious by now - I was wondering what would I need to add to the code to make it find that prefix, then insert it in front of the table name when it creates it? .... also, would I use the same code further in the code, for each call to the table? I can always fixs that part manually, if I have to, but I was guessing that there is probably just a little snippet of code I could use instead ....

    ....On a similar note, should this be a suggestion worthy of sending to the plug-in contest bunch? Perhaps suggesting that ontop of the "guidelines," if the plugin needs to create a table, that it keep in mind multiple installs in one db, and make sure to query the table prefix if the table will contain data that will "bug-up" multiple installs in one database? Just curious...

  2. rossz
    Member
    Posted 9 years ago #

    You'll need to find edit the plugin script to fix this.

    Add this after the comment at the top:

    $wpdb->category_visibility = $table_prefix . 'category visibility';

    Is there really a space in the table name? That's considered a very bad practice.

    Anyway, now go through the code and replace each reference to the table name with '$wpdb->category_visibility'.

    This is for 1.5. I don't know how to fix other versions.

  3. drobbins
    Member
    Posted 9 years ago #

    Well, I don't think there is a space in the table name - just very bad typing on my part ... Anyway, THANK YOU THANK YOU THANK YOU! .... you have saved me so much time, coffee, and clueless stares into a PHP manual and the WP code ...

  4. rossz
    Member
    Posted 9 years ago #

    I left out something. You'll probably need to add this to each function in the plugin that references $wpdb:

    global $wpdb;

  5. drobbins
    Member
    Posted 9 years ago #

    Ok - thanks - I am about to try it now on a fresh install and see if it works - if it does, should I make it available somewhere? - surely I am not the only hapless individual way over his head who had this problem ...

  6. drobbins
    Member
    Posted 9 years ago #

    Works like a charm! Many many thanks again! I'm just going to send this fix to the plug-in author and let him add it to the next version if he wants ... anyway, thanks!

  7. drobbins
    Member
    Posted 9 years ago #

    Oh - and just in case anyone stumbles across this forum with a similar problem, the "global $wpdb; " was already in the code after each function, fortunately - so I didn't have to change that ...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.