[Resolved] describing * in comment form

Home Forums Support [Resolved] describing * in comment form

Home Forums Support describing * in comment form

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #171285
    ian

    Hi

    In the comment form There are two “*”
    next to email and name

    These denote that these fields are optional
    I want to put a line of text to that effect but I can’t work out where to add it there doesn’t seem a suitable hook?

    Ian

    #171311
    Tom
    Lead Developer
    Lead Developer

    Hi Ian,

    You can use the comment_form_default_fields hook:

    add_filter( 'comment_form_default_fields','generate_comment_form_default_fields' );
    function generate_comment_form_default_fields()
    {
    	$fields = array(
    		'author' => '<input placeholder="' . __( 'Name','generate' ) . ' *" id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30" />',
    		'email' => '<input placeholder="' . __( 'Email','generate' ) . ' *" id="email" name="email" type="text" value="' . esc_attr(  $commenter['comment_author_email'] ) . '" size="30" />',
    		'url' => '<input placeholder="' . __( 'Website','generate' ) . '" id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" />',
    	);
    	
    	return $fields;
    }

    Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/

    #171575
    ian

    Hi

    Thanks that allows me to replace holding text within form fields

    What I really would like is to be able to put a line of text above the comment form like this

    on this site

    Is that possible with GP ?

    #171697
    Tom
    Lead Developer
    Lead Developer

    Ah, I understand.

    Currently it’s not possible without making a child theme, but I’ve added a hook in the next version.

    To make the change to your site currently, find the comments.php file in “Appearance > Editor”.

    Find this line:

    <?php // You can start editing here -- including this comment! ?>

    And replace it with this line:

    <?php do_action( 'generate_inside_comments' ); ?>

    Now you can use this function:

    add_action( 'generate_below_comments_title','generate_add_comment_desc' );
    function generate_add_comment_desc()
    { 
    ?>
        Your text for above the comments here
    <?php 
    }

    Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/

    Hope this helps πŸ™‚

    • This reply was modified 8 years, 1 month ago by Tom.
    #171925
    ian

    Thanks that is not quite in the right place

    see here
    http://sykic.co.uk/andbeyond/2016/01/26/boris/#comment-4

    it allows extra text above all the comments

    what I wanted is extra text under “Leave a comment” title just above the form

    Not the end of world if not possible

    Ian

    • This reply was modified 8 years, 1 month ago by ian.
    • This reply was modified 8 years, 1 month ago by ian.
    #171966
    Tom
    Lead Developer
    Lead Developer

    I think that position warrants a hook as well.

    In comments.php file the closing </h3> (line 32).

    Below it, add this:

    <?php do_action( 'generate_below_comments_title' ); ?>

    Then use the adjusted code I gave you above.

    This will be default in the next version πŸ™‚

    #172490
    ian

    Hi

    Thanks yet again

    Do you have a beta available somewhere to download ?

    Ian

    #172531
    Tom
    Lead Developer
    Lead Developer

    Not yet, but here’s the entire comments.php file: http://pastebin.com/d7LGX6z8

    Just replace the contents of yours with that code and you should be good to go πŸ™‚

    #173846
    ian

    Hi

    sorry its been a few days
    Thank you that all works well

    Just to confirm. That is how it will be in the next version you release ?

    Am I right in that it is not possible to uniquely format those bits of text with CSS ?

    Brilliant support
    Thanks

    Ian

    #173877
    Tom
    Lead Developer
    Lead Developer

    Correct, that’s the file in the next version πŸ™‚

    You can definitely use CSS to adjust the text, just wrap it in an HTML element with a class.

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.