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: 25394

    Hi Fabien,
    Thank you for the reply.

    I am not sure why the pointed you to us. Those topics are in some other context.

    I will show you why I asked you to request help from buddyx. By default, BuddyPress does not offer a template hook to put the confirm email after the email field. If we try to put one, here is what happens.

    https://i.ibb.co/3YCHxxK/Selection-489.png

    It goes below the password field.

    As a theme developer, they can either add it manually in their registration page or they can add a hook and provide you with the proper code.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25394
    Brajesh Singh on in reply to: Profile tab settings #44793
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 25394
    Brajesh Singh on in reply to: [Resolved] Suggestion #44792

    Hi Tosin,
    Thank you. We decided to go against the member type for profile field group to avoid confusion. BuddyPress core supports visibility of field by member type and adding our own for the field group was bound to have issue in future if BuddyPress core decided the same.
    That’s why we opted for role based settings.

    You may map a member type to role and then use this.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25394

    Hi Giuseppe,
    Thank you for the question.

    Please remove the above code and use this instead

    
    
    // Redirect from members directory.
    function buddydev_hide_members_directory_for_all_except_admin() {
    	if ( bp_is_members_directory() && ! is_super_admin() ) {
    		$url_to_redirect_to = "http://example.com/some-page";
    		bp_core_redirect( $url_to_redirect_to );
    	}
    }
    
    add_action( 'bp_template_redirect', 'buddydev_hide_members_directory_for_all_except_admin' );
    
    

    Please make sure to change your own url.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25394
    Brajesh Singh on in reply to: mediapress video screenshot #44790
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 25394

    Hi Tosin,
    Thank you for the reply.

    Although it is fine to do that, I will rather write a function. If you check, there are 3 things which vary field id, value and error message.

    You can remove the previous code and use the following instead.

    
    
    // forces user to select a specific select field value on registration page.
    add_action( 'bp_signup_validate', function () {
    	bd_tosin_validate_signup_field( 4448, 'I accept', 'This is a required field. You must accept.' );
    
    	// You can uncomment the below function and specify your value. Repeat it as you need.
    	// bd_tosin_validate_signup_field( 2, 'some other value', 'Your error message' );
    	// bd_tosin_validate_signup_field( 2, 'some other value', 'Your error message' );
    
    } );
    
    /**
     * Validates BuddyPress signup field.
     *
     * Makes sure that the user entered value is same as the expected value. If not, the specified error will be shown.
     *
     * @param int $field_id
     * @param string $expected_value expected value to match.
     * @param string $error_message Error message to be shown if the values do not match.
     *
     * @return void
     */
    function bd_tosin_validate_signup_field( $field_id, $expected_value, $error_message = 'Please try again, the value did not match our expectation' ) {
    
    	if ( ! isset( $_POST[ 'field_' . $field_id ] ) ) {
    		return; //should never happen if the field is marked as required.
    	}
    
    	$input_value = wp_unslash( $_POST[ 'field_' . $field_id ] );
    
    	if ( strtolower( $expected_value ) !== strtolower( $input_value ) ) {
    		buddypress()->signup->errors[ 'field_' . $field_id ] = $error_message;
    	}
    }
    

    And you can use it for as many fields as you need.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25394
  • Keymaster
    (BuddyDev Team)
    Posts: 25394

    Hi Eric,

    Welcome to BuddyDev support forums.

    Thank you for letting us know. we will be exploring and updating as needed.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25394
    Brajesh Singh on in reply to: [Resolved] Suggestion #44779

    Hi Tosin,
    thank you for the suggestion.

    Our Profile Data Control already does it.

    Please have a look.
    https://buddydev.com/plugins/buddypress-profile-data-control/

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25394
    Brajesh Singh on in reply to: [Resolved] Buddypress conditional registration #44769

    Hi tosin,
    Please use the following code

    
    
    // forces user to select a specific select field value on registration page.
    add_action( 'bp_signup_validate', function () {
    	$field_id       = 4448; // Your select field id.
    	$accepted_value = 'I accept'; // please change with the value you want to accept.
    
        if ( ! isset( $_POST[ 'field_' . $field_id ] ) ) {
    		return; //should never happen if the field is marked as required.
    	}
    
    	$selected_val = $_POST[ 'field_' . $field_id ];
    
    	if ( strtolower( $accepted_value ) !== strtolower( $selected_val ) ) {
    		buddypress()->signup->errors[ 'field_' . $field_id ] = __( 'This is a required field. You must accept.', 'buddypress' );
    	}
    
    } );
    

    please make sure to update the variable $accepted_value with the actual value which you have used for your selectbox.

    Regards
    Brajesh