Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)

  • ToobHed
    Participant

    @toobhed

    I’m not sure why I would need to hook to something? I am running this process independently as part of a currently working cron job. I want to add a routine to my cron job that would remove users from groups if they are of a certain role. I have everything working, except I am not able to find the groups a user belongs to. I believe the code $group_ids = BP_Groups_Member::get_group_ids( $user_id ); is correct since I get the intended results when I run this from the buddypress page for members. That page must contain all the necessary declarative and required components. When I run the same code in functions.php even supplying a known user id such as $group_ids = BP_Groups_Member::get_group_ids( 2); my array is empty. Furthermore I get the errors noted above that I do not get when running this code from the members page.


    ToobHed
    Participant

    @toobhed

    I am trying to call this outside of any buddypress files. I am calling it in my themes functions, it is to run on a cron. I must be missing a global or required file, any ideas?


    ToobHed
    Participant

    @toobhed

    Thanks for the reply,

    The code runs fine when I call it from “theme\buddypress\members\index.php” and outputs:
    rray(2) { [“groups”]=> array(6) { [0]=> string(1) “2” [1]=> string(1) “0” [2]=> string(2) “11” [3]=> string(1) “7” [4]=> string(2) “12” [5]=> string(2) “13” } [“total”]=> int(6) }

    But when I call it from functions.php in my theme I get the errors:

    Notice: Undefined property: BP_Groups_Component::$table_name_members in /home/vetsgami/public_html/wp-content/plugins/buddypress/bp-groups/classes/class-bp-groups-member.php on line 561

    Notice: Undefined property: BP_Groups_Component::$table_name in /home/myserver/public_html/wp-content/plugins/buddypress/bp-groups/classes/class-bp-groups-member.php on line 561

    Notice: Undefined property: BP_Groups_Component::$table_name_members in /home/myserver/public_html/wp-content/plugins/buddypress/bp-groups/classes/class-bp-groups-member.php on line 562

    Notice: Undefined property: BP_Groups_Component::$table_name in /home/myserver/public_html/wp-content/plugins/buddypress/bp-groups/classes/class-bp-groups-member.php on line 562
    array(2) { [“groups”]=> array(0) { } [“total”]=> int(0) }

    Makes me wonder if I need to include a file from buddypress to run it here?


    ToobHed
    Participant

    @toobhed

    Thanks for the help, I just decided to redirect them to a post with the desired error message.


    ToobHed
    Participant

    @toobhed

    Thanks for the help, pointing out groups_before_delete_group got me in the right direction. It would be nice as you pointed out to give a message, but for now, I only have a few admins, and simply want to block some core groups and this solves my problem.

    I messed around with trying to put in an admin notice but it seems when I exit the function it goes to a blank page. I’m no expert, I am sure there is an answer but for now this keeps my admins from deleting the important groups.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
Skip to toolbar