• Resolved joshvic1

    (@joshvic1)


    Hi I’d like to create a custom field like where people can input their Facebook link and the Facebook link must not be the same for any individual.

    I would like to make this the next page immediately after registering. How can I achieve this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Deepak Sharma

    (@sharmadpk03)

    Hi @joshvic1,

    Sorry for the delayed response.
    Regarding the query, I am a bit confused about what exactly are you looking to do. If you could explain to me your requirements in a bit more detail then it would be easy for me to assist you.

    Let me know and I will get back to you.

    Regards!

    Thread Starter joshvic1

    (@joshvic1)

    What I’m trying to ask is
    How can I create an extra field in the registration form where I want members to enter their Facebook link;

    Like if user A registers and enter https://www.facebook.com/grace12 as his Facebook link, another USER B must not be able to enter that same link,if any other person try entering that link, an error message will show that, link already exists.

    Do you understand.
    How can I achieve that

    Hi @joshvic1,

    Sorry for the delayed response.
    Regarding the query, there are no options readily available to do so but with a code snippet, you can achieve that. You will have to use a website/URL field in the form and it will work for that field only.

    Here’s the code that you need to copy and paste in your active theme’s functions.php file:

    add_action( 'user_registration_validate_user_url', 'ur_validate_user_url_field', 10, 4 );
    function ur_validate_user_url_field( $single_form_field, $data, $filter_hook, $form_id ) {
    	$field_label = isset( $data->label ) ? $data->label : '';
    	$value       = isset( $data->value ) ? esc_url( trim( $data->value, '/' ) ) : '';
    	$value_url   = parse_url( $value );
    	$user_list   = wp_list_pluck( get_users(), 'data' );
    	foreach ( $user_list as $user ) {
    		if ( false !== strpos( $user->user_url, $value_url['host'] ) ) {
    			add_filter(
    				$filter_hook,
    				function ( $msg ) use ( $field_label ) {
    					return __( $field_label . ' is already registered.', 'user-registration' );
    				}
    			);
    			break;
    		}
    	}
    }

    Let me know if it helps or not and I will get back to you.

    Regards!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to create a unique field that must not t be the same for multiple users’ is closed to new replies.