[解決済み] カスタムメンバーフィールドに記入例を付けたい。

フォーラム 使い方全般 [解決済み] カスタムメンバーフィールドに記入例を付けたい。

  • このトピックには3件の返信、3人の参加者があり、最後にswallowにより3年、 7ヶ月前に更新されました。
4件の投稿を表示中 - 1 - 4件目 (全4件中)
  • 投稿者
    投稿
  • #56759
    marin
    参加者

    カスタムメンバーフィールドに記入例を設けたいと思い、記事を参考に以下の通り’usces_filter_custom_field_input’にフィルターをかけてみたのですが、どうしてもエラーになってしまってうまくいきません。

    引数の渡し方がよく分かりません。
    add_filter( ‘usces_filter_custom_field_input’, ‘my_filter_custom_field_input’, 10, 3 );
    function my_filter_custom_field_input($html, $data, $custom_field, $position){
    $meta = usces_has_custom_field_meta($custom_field);
    $html = preg_replace(‘|([birthday])+”+s+(value=”” />)|’, ‘${0}1999/12/31’, $html);

    }

    エラーメッセージ
    Warning: Missing argument 4 for my_filter_custom_field_input()

    差し支えなければ正しいコードをお教えいただけないでしょうか?
    よろしくお願いいたします。。

    • このトピックはnanbuが8年、 8ヶ月前に変更しました。
    #67872
    marin
    参加者

    自己解決しました。

    引数の数の指定が間違っていました。

    #74826
    wtnb
    参加者

    ——————————————-
    WordPress のバージョン:
    Welcart のバージョン:1.4.17
    ご利用のテーマ:
    症状を確認したブラウザ:
    サーバー(会社名、サービス名):
    SSLの利用: 
    WordPress のパーマリンク設定:
    ——————————————–

    カスタムメンバーフィールドに例文を記述したい方は多いと思いますので、フックの記述を残しておきます。

    add_filter('usces_filter_custom_field_input', 'my_filter_custom_field_input', 1, 4);
    
    function my_filter_custom_field_input($html, $data, $custom_field, $position){
    $meta = usces_has_custom_field_meta($custom_field);
    $html = preg_replace('|(\\[birthday\])\\"+\\s+value="" />|', '${0}1999/12/31', $html);
    return $html;
    }
    #90525
    swallow
    参加者

    ——————————————-
    WordPress のバージョン:5.4.2
    Welcart のバージョン:1.9.31
    PHP のバージョン:7.3.16
    Welcart専用の拡張プラグインとバージョン:SKU Select 1.1.10
    ご利用のテーマ:EGO (TCD079/Welcart版)
    症状を確認したブラウザ:Chrome
    サーバー:
    SSLの利用:
    ——————————————–

    お世話になります。

    上記記事を見つけ、私もカスタムメンバーフィールドに記入例を設けたいと思い、
    functios.phpに下記記述をしてみたのですが、うまくいきません。

    add_filter(‘usces_filter_custom_field_input’, ‘my_filter_custom_field_input’, 1, 4);

    function my_filter_custom_field_input($html, $data, $custom_field, $position){
    $meta = usces_has_custom_field_meta($custom_field);
    $html = preg_replace(‘|(\\[birthday\])\\”+\\s+value=”” />|’, ‘${0}1999/12/31’, $html);
    return $html;
    }

    どこが間違えているのか、ご教授いただければと思います。
    よろしくお願いいたします。

4件の投稿を表示中 - 1 - 4件目 (全4件中)
  • このトピックに返信するにはログインが必要です。