Skip to:
Content
Pages
Categories
Search
Top
Bottom

BP_Activity_Component object appears to be missing $table_name. Anyone know why?

  • @jreeve

    Participant

    I’ve been getting weird errors when trying to log an activity item via bp_activity_add():

    WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '( user_id, component, type, action, content, primary_link, date_recorded, item_i' at line 1 for query INSERT INTO ( user_id, component, type, action, content, primary_link, date_recorded, item_id, secondary_item_id, hide_sitewide, is_spam ) VALUES ( 3163, 'members', 'new_member', '', '', '', '2015-07-16 15:47:00', 0, 0, 0, 0 ) made by require('wp-blog-header. php'), require_once('wp-load.php'), require_once('/srv/www/commons/current/web/wp-config. php'), require_once('wp-settings.php'), include('/themes/tuileries/functions.php'), bp_activity_add, BP_Activity_Activity->save

    As you can see, there’s no table name here. It should be INSERT INTO wp_bp_activities... or thereabouts. It looks like BP_Activity_Activity->save() is trying to access $bp->activity->table_name, but $bp->activity doesn’t have a table_name property at this stage. Instead, this is all that is in $bp->activity:

    
    BP_Activity_Component Object
    (
        [name] => Activity Streams
        [id] => activity
        [slug] =>
        [has_directory] =>
        [path] => /srv/www/commons/current/web/app/plugins/buddypress/
        [query] =>
        [current_id] =>
        [notification_callback] =>
        [admin_menu] =>
        [search_string] =>
        [root_slug] =>
        [meta_tables] => Array
            (
            )
    
        [global_tables] => Array
            (
            )
    
        [adminbar_myaccount_order] => 10
    )

    Why isn’t there a table name here? How can I fix this?

Viewing 4 replies - 1 through 4 (of 4 total)
  • @shanebp

    Moderator

    >Why isn’t there a table name here?

    It’s probably a timing issue – the name hasn’t been set at the point where you run your code.

    What hook are you using for the function that uses bp_activity_add ?

    @jreeve

    Participant

    I’m putting this in my theme’s functions.php, just to test it out there. But the function will eventually be triggered when a user registers for the site, wherever that appears in the code.

    @shanebp

    Moderator

    Use a hook for testing, something like:

    function jr_test() {
       bp_activity_add(...); 
    }
    add_action( 'bp_ready', 'jr_test' );

    @jreeve

    Participant

    You’re right–putting it lower in the loading order fixed it. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘BP_Activity_Component object appears to be missing $table_name. Anyone know why?’ is closed to new replies.
Skip to toolbar