• 解決済 1harry1

    (@1harry1)


    【実現したい事】

    simple member shipの登録フォームに、placeholderを追記したいです。

    【試した事】

    該当箇所部分にplace holderを記載→プラグインをアップデートすると、カスタマイズが消えるとの情報で
    別方法を探しております。

    【調べたこと】

    phpファイルにadd_fillterを記載したコードを書くと、プラグインがアップデートされても、カスタマイズは消えないと分かりました。しかし、どんなコードを書けば、実現したいことが出来るかが、わからない状態です。

    ご教授、お願いします。

    • このトピックは1harry1が4年、 2ヶ月前に変更しました。
    • このトピックは1harry1が4年、 2ヶ月前に変更しました。
5件の返信を表示中 - 1 - 5件目 (全5件中)
  • こんにちは

    ショートコードの出力をフィルタリングする do_shortcode_tag フィルターフックぐらいしかなさそうです。

    例:

    add_filter( 'do_shortcode_tag', function( $output, $tag ) {
    	if ( 'swpm_registration_form' === $tag ) {
    
    		// ここで HTML ($output) を変更
    		// $output = str_replace( '<input type="text" id="user_name"', '<input type="text" id="user_name" placeholder="名前を入力"', $output );
    
    	}
    	return $output;
    }, 10, 2 );
    トピック投稿者 1harry1

    (@1harry1)

    有難うございます!
    無事、表示されました。
    また、ショートコードの出力方法も教えて頂きまして、有難うございます。

    トピック投稿者 1harry1

    (@1harry1)

    ishitaka様、度々、申し訳ありません。

    パスワードの部分についても、同様にplaceholderを使用したく、教えて頂きましたコードを参考に、下記を記載しましたが、表示がされないのですが、この場合は、全く違うコードの書き方になるのでしょうか?

    add_filter( 'do_shortcode_tag', function( $output, $tag ) {
    	if ( 'swpm_registration_form' === $tag ) {
    
    		$output = str_replace( '<input type="password" id="password"', '<input type="password" id="password" placeholder="8文字以上の半角英数字"', $output );
    	}
    	return $output;
    }, 10, 2 );

    自身でも、教えて頂いたコードを元に検索してみましたが、(知識不足により)解決に繋がらず、再度ご質問させて頂きました。お手隙の際に、教えて頂けますと幸いです。

    パスワードフィールドは、

    <input type="password" autocomplete="off" id="password" class="" value="" size="50" name="password">

    です。よって、

    $output = str_replace( '<input type="password" autocomplete="off" id="password"', '<input type="password" autocomplete="off" id="password" placeholder="8文字以上の半角英数字"', $output );

    または、

    $output = str_replace( 'id="password"', 'id="password" placeholder="8文字以上の半角英数字"', $output );

    こんな感じでしょうか。

    トピック投稿者 1harry1

    (@1harry1)

    とても、ご丁寧に有難うございます。

    パスワードフィールドについて、検証モードで確認しましたら、仰せの通りでした(私に確認ミスでした)。
    非常に、勉強になり、重ねて感謝申し上げます。

5件の返信を表示中 - 1 - 5件目 (全5件中)
  • トピック「simple member shipの登録フォーム」には新たに返信することはできません。