Skip to:
Content
Pages
Categories
Search
Top
Bottom

Registration and Members Listing with BP API


  • gosselind
    Participant

    @gosselind

    Hello everyone,

    I’m trying to build the frontend part for my blog and use WP and BP as headless CMS through their API. But I can’t get the registration to work as I expect. What I would like is to

    • Have a registration form for new users to sign up.
    • Once they’re registered and after account activation, they appear in member list so that other users can make friendship request to them.
    • When they’re registered and after account activation they can log in (with JWT) and then display the memeber list to make friendship request.

    What I’ve done, what’s not working

    • When I try to make a “create member request” via POST /buddypress/v1/members -> I get an error “rest_cannot_create_user” because I don’t have rights to create new members.
    • When I try to make a “signup request” via POST /buddypress/v1/signup, it registration seems to works (a user is added in WP) but he’s not visible in member list via GET /buddypress/v1/members.
    • After account activation, the user is still not present in the member list
    • After the user has logged in via JWT (POST /jwt-auth/v1/token), he can access to member list but he is still not present in the member list.
    • The only way I found to make the user appears in the member list is to log in with the user credentials on the wp-admin interface.

    How can I solve this, i.e. how can I make a new user visible in the member list without having him to log in through the wp-admin page ?

    And this may be related but what is the difference between “user signups” and “member creation” ?

    Thanks,
    David

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

  • shanebp
    Moderator

    @shanebp

    If you create a ‘last_activity’ entry in the activities table, the user should appear in the members list.
    For example, once you have the user id:
    bp_update_user_last_activity( $user_id, bp_core_current_time() );


    gosselind
    Participant

    @gosselind

    Hi shanebp,

    Thanks a lot ! Adding these lines in my functions.php solved the problem

    function update_last_activity_on_activation( $user ) {
    
    	
    	if ( empty( $user ) ) {
    		return false;
    	}
    
    	if ( is_array( $user ) ) {
    		$user_id = $user['user_id'];
    	} else {
    		$user_id = $user;
    	}
    
    	if ( empty( $user_id ) ) {
    		return false;
    	}
    
    	bp_update_user_last_activity( $user_id, bp_core_current_time() );
    
    }
    add_action( 'bp_core_activated_user', 'update_last_activity_on_activation' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar