Support » Plugin: BP Profile Search » Add prefix to USER ID when search

  • Resolved pracol

    (@pracol)


    WordPress generate the user id each time when new user register. In BP search form there is one option “ID”. which accept and search the ID well. However, I wish that user type the prefix as “IND23” including with the user ID and then the form accept and give the result. If the user only type the ID without Prefix, the result should not should any thing.

    Thank You

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Andrea Tarantini

    (@dontdream)

    Hello @pracol,

    Sorry I missed your post! Please let me know if you still need help with this.

    Is is not solved yet.

    Plugin Author Andrea Tarantini

    (@dontdream)

    Hi pracol,

    Do you mean that, when the user enters ‘IND456’ in the ID search field, the plugin should search for ‘456’ instead?

    Yes, Exactly I need this. “when the user enters ‘IND456’ in the ID search field, the plugin should search for ‘456’. and when the user enters ‘456’ in the ID search field, The plugin should not search any thing”.

    Thank You

    Plugin Author Andrea Tarantini

    (@dontdream)

    Please try adding this code to your bp-custom.php file:

    add_action ('bps_edit_field', 'ID_format');
    function ID_format ($f)
    {
    	if ($f->code == 'ID')
    		$f->format = 'text';
    }
    
    add_filter ('bps_request', 'ID_prefix', 10, 3);
    function ID_prefix ($request, $type, $form)
    {
    	if ($type == 'search' && isset ($request['ID']))
    		$request['ID'] = (strpos ($request['ID'], 'IND') === 0)? substr ($request['ID'], 3): 'invalid';
    
    	return $request;
    }

    Thanks a lot. This code works fine.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add prefix to USER ID when search’ is closed to new replies.