kuckovic
Forum Replies Created
-
Forum: Everything else WordPress
In reply to: Noindex TagWhat plugins do you have installed?
Maybe WordPress SEO can help you figure out what the issue is? I know it tells you if your page has indexing-issues.Might be worth a shot.
Forum: Everything else WordPress
In reply to: Noindex TagHi @cregy
Do you, by any chance, have “Discourage search engines from indexing this site” checked under “Settings” > “Reading” (in the controlpanel)?
/A
Forum: Fixing WordPress
In reply to: WordPress Site High CPU Usage (Help)Glad it’s working now! 😀
Forum: Fixing WordPress
In reply to: WordPress Site High CPU Usage (Help)Hi @juanwp22
Any news on this matter?
Forum: Fixing WordPress
In reply to: Can’t edit pagesHave you tried deactivating all plugins, and then activating the TwentyTwentyFour theme?
And your WordPress is up to date?Forum: Fixing WordPress
In reply to: How can i add custom display name for user role in comments?Forum: Fixing WordPress
In reply to: Can’t edit pagesHmm – that seems to be a WooCommerce issue – but that’s only a deprecation-warning, and not a fatal error. This error is discussed in this GitHub thread.
Does the issue still perssist if you change the theme to the default TwentyTwentyFour theme??Forum: Fixing WordPress
In reply to: How can i add custom display name for user role in comments?I’ve updated the code here below.
I’ve wrapped the “Admin” word in <span>-tags with a class – you should be able to play around with that.<?php
/** Add User Role to Comments. */
if ( ! class_exists( 'Comment_Author_Role_Label' ) ) :
class Comment_Author_Role_Label {
public function __construct() {
add_filter( 'get_comment_author', array( $this, 'get_comment_author_role' ), 10, 3 );
add_filter( 'get_comment_author_link', array( $this, 'comment_author_role' ) );
}
function get_comment_author_role($author, $comment_id, $comment) {
$authoremail = get_comment_author_email( $comment );
if (email_exists($authoremail)) {
$comment_user = get_user_by( 'email', $authoremail );
$comment_user_role = $comment_user->roles[0];
switch ($comment_user_role) {
case 'administrator':
$this->comment_user_role = ' <span class="comment-admin">Admin</span>';
break;
default:
$this->comment_user_role = ' ' . ucfirst($comment_user_role);
break;
}
} else {
$this->comment_user_role = '';
}
return $author;
}
function comment_author_role($author) {
return $author .= $this->comment_user_role;
}
}
new Comment_Author_Role_Label;
endif;Forum: Fixing WordPress
In reply to: Can’t edit pagesWow! That’s a lot of errors!
Have you updated all your plugins, themes and WP Core?Forum: Fixing WordPress
In reply to: How can i add custom display name for user role in comments?@stellaa
I would suggest you look into some CSS.
If the label does not have a CSS-class, you can add it in the code above.
But from what I can see in the screenshot, you should have a different class, based on userroles./A
Forum: Fixing WordPress
In reply to: Can’t edit pagesHi @freddyeee
If you check your console in the inspector tools, do you see any JS errors here?
This could help identify the problem.
/AForum: Fixing WordPress
In reply to: Plugin CARBON FIELDS stopped working after the update(ERROR JS)Hi @ruslanbay
Looking at their GitHub, they’re aware of this problem.
You can read more about the issue here
Long story short, they recommend you to update Carbon Fields to the newest version.
/AForum: Fixing WordPress
In reply to: Need Help 😠The editor has encountered an unexpected errorForum: Developing with WordPress
In reply to: Bulk update existing patterns?Thanks a lot, Justin 🙂
Forum: Fixing WordPress
In reply to: How can i add custom display name for user role in comments?Hi @stellaa
I assume you want to change “Administrator” to something else – and not the name “peter”.
In the code you’ve provided, it fetches the userrole here:$comment_user_role = $commet_user_role->roles[0];
And then it sets the first letter to capital here (ucfirst):$this->comment_user_role = ' ' . ucfirst($comment_user_role) . '';
If you want to change the administrator role so something else – let’s say you would like it to say “Admin” instead – then I would change the code to look something like this:/** Add User Role to Comments. */
if ( ! class_exists( 'Comment_Author_Role_Label' ) ) :
class Comment_Author_Role_Label {
public function __construct() {
add_filter( 'get_comment_author', array( $this, 'get_comment_author_role' ), 10, 3 );
add_filter( 'get_comment_author_link', array( $this, 'comment_author_role' ) );
}
function get_comment_author_role($author, $comment_id, $comment) {
$authoremail = get_comment_author_email( $comment );
if (email_exists($authoremail)) {
$comment_user = get_user_by( 'email', $authoremail );
$comment_user_role = $comment_user->roles[0];
switch ($comment_user_role) {
case 'administrator':
$this->comment_user_role = ' Admin';
break;
default:
$this->comment_user_role = ' ' . ucfirst($comment_user_role);
break;
}
} else {
$this->comment_user_role = '';
}
return $author;
}
function comment_author_role($author) {
return $author .= $this->comment_user_role;
}
}
new Comment_Author_Role_Label;
endif;Please note, I’m checking if the user is an “administrator”, before changing the name to “Admin” – you should also check for “Editor”, “Author”, “Contributor” and “Subscriber”. If you ONLY want to apply a custom label for the “administrator” userrole, then you can set the “default” (in the switch case) to an empty string, like this:
default:
$this->comment_user_role = '';
break;Hope this helps 🙂
/A- This reply was modified 1 year, 10 months ago by kuckovic. Reason: Corrected copy/pasted part of code