[Resolved] Help with functions code not working in GP

Home Forums Support Help with functions code not working in GP

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #1326779

    This may or may not be related to GP but I used to run this code in the previous theme and it worked. It’s a script inside fucntions.php to show ad “Admin” label for authors of the blog post within WordPress comments. Since launching 2 sites in GP, I cannot even get WordPress to accept this inside functions.php. Check another old site not using GP and it still works. Maybe someone who has more expertise in this area can guide me through this? When I try to add this inside WP Editor for functions.php, I get this error: “syntax error, unexpected ‘}’, expecting end of file”

    // Get comment author role
    function wpb_get_comment_author_role($author, $comment_id, $comment) {
    $authoremail = get_comment_author_email( $comment);
    // Check if user is registered
    if (email_exists($authoremail)) {
    $commet_user_role = get_user_by( ’email’, $authoremail );
    $comment_user_role = $commet_user_role->roles[0];
    // HTML output to add next to comment author name
    // $this->comment_user_role = ‘ <span class=”comment-author-label comment-author-label-‘.$comment_user_role.'”>’ . ucfirst($comment_user_role) . ‘</span>’;
    $this->comment_user_role = ‘ <span class=”comment-author-label comment-author-label-‘.$comment_user_role.'”>admin</span>’;
    } else {
    $this->comment_user_role = ”;
    return $author;

    // Display comment author
    function wpb_comment_author_role($author) {
    return $author .= $this->comment_user_role;
    new WPB_Comment_Author_Role_Label;

    Customer Support

    Hi there,

    I’m not sure what this code does unfortunately.

    Does it work in a twenty series default WP theme?

    Let me know πŸ™‚


    Hey Leo,

    I see where you are heading with this. Your comment pointed me to spin up a staging site and swapping the theme. Turns out, WordPress Editor does not allow this php function to be inserted. I SFTP’ed in and made adjustments there and the code stuck.

    For the record, this bit of code adds a label (ie. administrator, author, subscriber etc..) beside the commenter’s name.

    Thank you!

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