0

buddypress でカスタム/条件付き登録/プロファイル フィールドを作成する方法はありますか。これについてグーグルでいろいろ試しましたが、適切な解決策が得られません。私が考えている条件は次のとおりです。

2/3 ドロップダウンを作成したいのですが、最初のドロップダウンに車両の種類 (車、自転車) が含まれている場合、2 番目のドロップダウンのオプションは、ユーザーがドロップダウン 1 で選択した内容に応じて変更する必要があります。

任意の助けをいただければ幸いです。事前に感謝します。:-)

4

2 に答える 2

0

register/registration.php のソースに手を加えない限り、少しトリッキーになります。jqueryに慣れていない場合は、このようにすることができます。登録フォームのどのフィールドをサーバーに伝える、budypress 登録フォームの非表示フィールド ( id "signup_profile_field_ids" ) があり、次のようになります。

<input type="hidden" name="signup_profile_field_ids" id="signup_profile_field_ids" value="5,11,1,10,32">

そのフィールドの値には、登録フォームのフィールド ID が含まれます。

次に、条件付きフィールドを表示する親フィールドを選択する必要があります。親フィールドと条件付きフィールドの ID を知る必要があります

このjqueryコードを使用してください

<script type="text/javascript">
  $(function(){
   var childs = new Array("Child id 1","Child id 1"); // your child fields ids
   var options = new Array("Car","Bike"); // your parent field options, notice option and child number is same, which means, one child for one option
   var parent = "Parent Field id"; // place you parent field id
   var currentFields = new Array();
   currentFields = $("#signup_profile_field_ids").val().split(','); // take all current fields ids in an array


   $.each(childs, function(index,value){
     $('#field_'+value).parent().hide(); // hide all child fields first
     currentFields.splice(currentFields.indexOf(value),1);
   });
   $("#signup_profile_field_ids").val( currentFields.join() );
   $('#field_'+parent).after('<div id="conditional-fields-conteiner></div>"');
   $('#field_'+parent).change(function(){
      var option = $(this).val();
      var appendField = childs[options.indexOf(option)];
      var html = $("#field_"+appendField).parent().html();
      $('#conditional-fields-conteiner').html(html);
      $.each(childs, function(index,value){
        currentFields.splice(currentFields.indexOf(value),1);
      });
      currentField[] = appendField;
       $("#signup_profile_field_ids").val( currentFields.join() );
    });
  });
</script>

これは複雑に思えるかもしれませんが、これが最も簡単な方法です。会員サイトで使用する予定がある場合は、使用しないでください。ユーザーは、html を編集するだけで条件付きフィールドを操作できます。

このためのプラグインもあり、まもなくリリースされます。開発しています

http://rimonhabib.com/coming-up-next-buddypress-nested-conditional-fields/

于 2013-06-17T08:06:22.463 に答える
0

現在、そのための機能するプラグインやハックはありません。いくつかのサイトでそのようなことを見ましたが、これは JavaScript を介して行われ、登録ページのソース コードが大幅に変更されています。

于 2013-05-16T13:09:08.097 に答える