Skip to:
Content
Pages
Categories
Search
Top
Bottom

BP helper functions not working

  • @mjhmatt

    Participant

    Hi,

    Whenever I try and user a function in BP core I get an error when it involves inserting/updating to the database.

    For example groups_join_group() – I’ve managed to trace the issue back to the insert statement and the table names are always null. This happens for every function whether it be selecting or inserting, is this a common issue or am I doing something strange?

    Thanks,

    Matt

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

    Moderator

    Without some context of what you’re trying to do and the errors you see, it is difficult to make suggestions. Use gist to share your code.

    @mjhmatt

    Participant

    So I’m trying to add a user to a group using the following code:

    https://gist.github.com/mjhmatt/921925740e5a3ec54efb2b681035d5e6

    However I’ve followed it back to this function:

    https://gist.github.com/mjhmatt/9cdae95190bfb77e7015c4bc00431a6a

    and {$bp->groups->table_name_members} is always NULL so it returns false.

    @shanebp

    Moderator

    BP functions need to be used in WP & BP context.
    For example, they should not be called until BP is loaded and ready – use the ‘bp_ready’ hook.
    And use the WP db functions – see $wpdb
    If you want to use vanilla php and mysqli, then you’ll need to roll your own join group function.

    @mjhmatt

    Participant

    Thanks Shane I get that.

    Im trying to access BP from within wp-admin – it seems BP ready doesn’t get called within the backend?

    Is there a way around this?

    Thanks

    @shanebp

    Moderator

    bp_ready is a hook.
    It doesn’t get called, you use it to make a call.
    Look at the code for BP settings in wp-admin.
    Perhaps there is another way to make a call after BP is loaded and ready.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar