Shape the future of Social networking with WordPress: Join Project Midnight Sun! The next generation platform for community building with WordPress!

BuddyDev

Search

Replies

  • Keymaster
    (BuddyDev Team)
    Posts: 25328
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 25328

    Hi ,
    You are welcome.

    Try this one

    
    $recipients_ids = wp_list_pluck( $message->recipients, 'user_id' );
    

    It should give an array of user ids.

    About the thread:- In BuddyPress, it is possible to have multiple people involved in a common message. It is accomplished via thread. All messages have a thread id(think of it as a topic id) which BuddyPress uses to relate the replies.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25328

    Hi maimaimemain,
    Thank you for asking.
    For you, the appropriate action is

    
    messages_message_before_save
    or 
    messages_message_after_save
    
    

    You can hook to it like

    
    
    function your_message_action_handler( $message ) {
    }
    add_action('messages_message_after_save', 'your_message_action_handler');
    
    

    $message is ‘BP_Messages_Message’ object and you can access the details

    Please do note that hook does not allow to differentiate between a new thread and an existing one.

    To do that, you might need to hook to

    
    
    messages_message_before_save
    
    

    and check for empty thread id.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25328

    Hi Joss,
    Please see
    https://youtu.be/nZQX_nOzpV4

    If you need the Conditional profile fields to work with Member Types Here are a few things to remember.

    1. Fields must be available to all member types
    2. The member type field type should be Single(Multi member type field type is not supported)
    3. You need to use the member type names while assigning conditions.

    Please see the video for details.

    Hope that helps.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25328

    Hi Carsten,
    Is there any specific reason for having 2 identical roles? Can’t the two type of user use two different member type but have same role?

    If you need to create custom role, you will need a plugin like User Roe Editor.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25328

    Hi Joss,
    Welcome to BuddyDev forums.

    Are you trying to put conditions on registration? BuddyPress does not support member type based condition fields on registration.

    There are two possible way to solve it
    1. Use conditional profile fields(I will explain how)
    2. Or do not use fields which are specific to a member type, let the user select their member type on registration and then they can update the member type specific profile fields on edit profile(If you want to force users to complete it, we have released BuddyPress Profile completion a few days ago)

    1. Fields which are associated with member type does not appear on registration:- The functionality to associate fields with member types is provided by BuddyPress.
    Currently, if you mark a field available to certain member types, they will not appear on registration. This is the way BuddyPress fetches fields.

    If you need users to select member type and then fields related to that member type, the solution is to mark fields available to all member types.

    After that, use the Conditional Profile field plugin to set conditions on each field based on the member type field.

    If your member type field is select/radio, this will work.

    This approach is fine but it needs extra work.

    A better strategy is if possible, let users select their member type on registration field. Avoid fields related to member type on registration screen.

    Once the user logs in, BuddyPress will only show them the fields which are available to their member type.

    Please let me know if any of the above two ways works for you?

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25328

    You are welcome 🙂

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25328

    Hi maimaimemain,
    Thank you.

    Glad it worked.

    All the best with your project.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25328

    Hi Daniel,
    Please use the following code

    
    
    /**
     * Redirect from new post creation screen.
     */
    function buddyblog_new_post_redirect() {
    	if ( ! is_user_logged_in() || ! bp_is_current_component( 'buddyblog' ) ) {
    		return;
    	}
    
    	if ( bp_is_current_action( 'edit' ) && ! bp_action_variable( 0 ) ) {
    		$redirect_url = site_url( '/create-new-blog/' );
    		bp_core_redirect( $redirect_url );
    	}
    }
    
    add_action( 'bp_template_redirect', 'buddyblog_new_post_redirect' );
    

    That will work.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25328

    Hi maimaimemain,
    Thank you. I am doing well. Hope you are doing well too.

    Sincerely appreciate the kind words and concern.

    Wow, I never knew Tokyo is so much colder in day(Googled it):)

    About the code:- It needs slight update. Here is a another version(with a different hook)

    
    function buddydev_custom_first_login_action( $redirect_to, $redirect_url_specified, $user ) {
    
    	//check if we have a valid user and bp exists?
    	if ( is_wp_error( $user ) || ! function_exists( 'bp_get_user_last_activity' ) ) {
    		return $redirect_to;
    	}
    
    	//check for user's last activity
    	$last_activity = bp_get_user_last_activity( $user->ID );
    
    	if ( empty( $last_activity ) ) {
    		// since BuddyPress did not record activity earlier, This is our first login.
    		// you can put any action here.
    	}
    
    	return $redirect_to; // please do not forget to return it.
    }
    
    add_filter( 'login_redirect', 'buddydev_custom_first_login_action', 110, 3 );
    
    

    You can put any code inside that if block to execute, and it should.

    Please give it a try. If it does not work, Please post me the modified code and I will assist quickly.

    PS:- The strategy from your first post will work too, we just need to slightly modify that. I liked the simplicity of that strategy.

    Best regards
    Brajesh