BuddyDev

Search

[Resolved] Error when trying to get member type

Tagged: 

  • Participant
    Level: Enlightened
    Posts: 26
    Ahmed on #29640

    Hi,

    I’m trying to get current user member type, but i have an error,
    here my constructor

    /**
         * @var array|bool|string member type de l'utilisateur (speacker, particpant etc..)
         */
        private $member_type;
    
        /**
         * @var int id de l'utilisateur courrant
         */
        private $user_id;
    
        public function __construct()
        {
            $this->user_id = wp_get_current_user()->ID;
            $this->member_type = bp_get_member_type($this->user_id);
            
            dump($this->member_type);die();
        }

    My dump return false, and have this errors : array_merge(): Expected parameter 2 to be an array, object given in C:\laragon\www\yoostart\web\app\plugins\buddypress\bp-core\bp-core-taxonomy.php on line 145.
    Warning: Invalid argument supplied for foreach() in C:\laragon\www\yoostart\web\app\plugins\buddypress\bp-members\bp-members-functions.php on line 2763.

    Any idea?

    Thanks.

  • Keymaster
    (BuddyDev Team)
    Posts: 22513
    Brajesh Singh on #29641

    Hi Ahmed,

    You are calling the function too early. Please make sure it is called on/after bp_init and it will work.

    Regards
    Brajesh

  • Participant
    Level: Enlightened
    Posts: 26
    Ahmed on #29655

    Hi Brajesh,

    that’s work with bp_init.
    Thank you.

    Regards
    Ahmed

  • Keymaster
    (BuddyDev Team)
    Posts: 22513
    Brajesh Singh on #29660

    You are welcome.

The topic ‘ [Resolved] Error when trying to get member type’ is closed to new replies.

This topic is: resolved