WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Where to find this text and change it (6 posts)

  1. makta112
    Member
    Posted 1 year ago #

    Hello friends

    So if you log in to my site and then click on a post, you will see this text by the comments: "Logged in as [name of user]. Log out?"

    I want to change that text, but I seem to be unable to find it. I've searched through all folders and still couln't find it.

    Help please.

  2. alchymyth
    Forum Moderator
    Posted 1 year ago #

    this is some of the outputs of comment_form()

    http://codex.wordpress.org/Function_Reference/comment_form

    try to add this to functions.php of the child theme:

    add_filter( 'comment_form_defaults', 'twentyelevenchild_modify_comment_fields' );
    
    function twentyelevenchild_modify_comment_fields( $fields ) {
    $user = wp_get_current_user();
    $user_identity = $user->exists() ? $user->display_name : '';
    $fields['logged_in_as'] = '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>';
    
    return $fields;
    }

    (the above is still the original text)

  3. makta112
    Member
    Posted 1 year ago #

    It worked, alchymyth. Thank you!

  4. makta112
    Member
    Posted 1 year ago #

    btw, alchymyth, I want to add this to functions.php too:

    <p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>

    But I'll have to add some text to make it work right? Could please me. What do I need to add to this code?

    Thank.

  5. alchymyth
    Forum Moderator
    Posted 1 year ago #

    add it to the filter:

    add_filter( 'comment_form_defaults', 'twentyelevenchild_modify_comment_fields' );
    
    function twentyelevenchild_modify_comment_fields( $fields ) {
    $user = wp_get_current_user();
    $user_identity = $user->exists() ? $user->display_name : '';
    $fields['logged_in_as'] = '<p class="logged-in-as">' . sprintf( __( 'Logged in as <a href="%1$s">%2$s</a>. <a href="%3$s" title="Log out of this account">Log out?</a>' ), admin_url( 'profile.php' ), $user_identity, wp_logout_url( apply_filters( 'the_permalink', get_permalink( ) ) ) ) . '</p>';
    $fields['must_log_in'] = '<p class="must-log-in">' . sprintf( __( 'You must be <a href="%s">logged in</a> to post a comment.' ), wp_login_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ) ) . '</p>';
    return $fields;
    }
  6. makta112
    Member
    Posted 1 year ago #

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic