The MU forums have moved to WordPress.org

Plugin Error (9 posts)

  1. DailyTestimony
    Member
    Posted 15 years ago #

    So I am writing a message to allow me to customize a message for display in the admin menu. It's complete I can load most pages without error, it correctly added a configuration tab in the admin panel under the site admin tab for me, but when i goto the tab it displays:

    Warning: call_user_func_array() [function.call-user-func-array]: First argument is expected to be a valid callback, 'am_page' was given in /home/dtnet/public_html/wp-includes/plugin.php on line 311

    Instaed of my page, the current code for this plugin can be found at: http://dailytestimony.net/plugins/debug/AdminMessage.txt

  2. zappoman
    Member
    Posted 15 years ago #

    the 6th parameter to add_submenu_page() needs to be a function name.

    In this case you want to pass "am_show_page" not "am_page" or you need to change your function name to "am_page" instead of "am_show_page"

    Good luck.

  3. DailyTestimony
    Member
    Posted 15 years ago #

    ah see I don't know how to use the function add_submenu_page(), I just copied it from another plugin and changed it how I thought it should be changed.

    EDIT: Now I got Fatal error: Call to a member function get_results() on a non-object in /home/dtnet/public_html/wp-content/mu-plugins/AdminMessage.php on line 58

    It appears there is a problem with how i'm doing my queres, line 58 is the first query for it to execute.

    see code link again I updated it

  4. lunabyte
    Member
    Posted 15 years ago #

    $curmsg = $wpdb->get_results("SELECTmessageFROMadmin_message");

    Later on, you spit out $curmsg. You can't do that, because it's an object array.

    If you printed the array, it would show something like this:

    stdClass Object
    (
        [message] => this is the admin message content
    )

    Meaning, you need to spit out $curmsg->message or right after your query, set $curmsg = $curmsg->message

    Basic, basic, basic stuff here.

  5. DailyTestimony
    Member
    Posted 15 years ago #

    to YOU it's basic, not to someone still learning php

    I still don't get the whole object stuff

    Besides that doesn't explain the error

    Fatal error: Call to a member function get_results() on a non-object

  6. lunabyte
    Member
    Posted 15 years ago #

    OK, let's see what's cooking then.

    First, did you create a new table called admin_message? That's what you're calling.

    "SELECTmessageFROMadmin_message"

    That means "select all results in the 'message' field from the 'admin_message' table.

    Honestly, you made a new table just for this field, and that's a little past ridiculous.

    You should instead be storing it in the site options table, and not even needing the wpdb object at all.

    1 table for 1 setting is a little abusive, really.

    Not to mention that if there was a call for a table, you're failing to properly prefix its name, so now someone would have a table just named admin_message sitting around.

    Whether it's WP, MU, or whatever, that's just bad practice.

    Best bet would be to completely rethink what you're doing here, scrap it, and try again.

  7. DailyTestimony
    Member
    Posted 15 years ago #

    I'm going with what I know here, I don't know how to create, change, and read site options.

  8. lunabyte
    Member
    Posted 15 years ago #

    No better time to learn, then.

  9. DailyTestimony
    Member
    Posted 15 years ago #

    oh this is useful: http://codex.wordpress.org/WPMU_Functions

    it would be nice for there was more wpmu stuff there though.

    This will be alot simpler:

    add_site_option ( $key, $value )
    get_site_option ( $key, $default = false, $use_cache = true )

    EDIT: That was SO much simpler, thanks a bunch lunabyte!I'm off to package it up for release now. I'll start a seperate thread for it when it's out.

About this Topic

  • Started 15 years ago by DailyTestimony
  • Latest reply from DailyTestimony