Ranks on the forum
Quote from DxLwebs on May 31, 2017, 5:14 pmI re-coded it for now with:
function my_asgarosforum_after_post_administration($author_id, $author_posts) { $user_info = get_userdata($author_id); if (user_can( $user_info, 'administrator')) { echo '<div class="icon-status-admin">'.__('Admin','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if (user_can( $user_info, 'moderator')) { echo '<div class="icon-status-moderator">'.__('Moderator','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(user_can( $user_info, 'contributor')) { echo '<div class="icon-status-contributor">'.__('Contributor','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(user_can( $user_info, 'author')) { echo '<div class="icon-status-author">'.__('Author','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(user_can( $user_info, 'editor')) { echo '<div class="icon-status-editor">'.__('Editor','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(user_can( $user_info, 'subscriber')) { echo '<div class="icon-status-editor">'.__('N00B','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } } } } } } }
I re-coded it for now with:
function my_asgarosforum_after_post_administration($author_id, $author_posts) { $user_info = get_userdata($author_id); if (user_can( $user_info, 'administrator')) { echo '<div class="icon-status-admin">'.__('Admin','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if (user_can( $user_info, 'moderator')) { echo '<div class="icon-status-moderator">'.__('Moderator','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(user_can( $user_info, 'contributor')) { echo '<div class="icon-status-contributor">'.__('Contributor','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(user_can( $user_info, 'author')) { echo '<div class="icon-status-author">'.__('Author','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(user_can( $user_info, 'editor')) { echo '<div class="icon-status-editor">'.__('Editor','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(user_can( $user_info, 'subscriber')) { echo '<div class="icon-status-editor">'.__('N00B','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } } } } } } }
Quote from Lung on July 24, 2017, 9:43 pmQuote from Yworld on January 18, 2017, 6:52 amAdd the the rank to the forum:
- administrator
- moderator
- contributor
- author
- editor
To do this you just have to add this code to your themes functions.php file:
add_action('asgarosforum_after_post_author', 'my_asgarosforum_after_post_administration', 10, 2); function getUserRoles($id) { $user = new WP_User((int)$id); return implode(' and ', $user->roles); } function my_asgarosforum_after_post_administration($author_id, $author_posts) { if (getUserRoles($author_id)=='administrator') { echo '<div class="icon-status-admin">'.__('Admin','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if (AsgarosForumPermissions::isModerator($author_id)) { echo '<div class="icon-status-moderator">'.__('Moderator','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(getUserRoles($author_id)=='contributor') { echo '<div class="icon-status-contributor">'.__('Contributor','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(getUserRoles($author_id)=='author') { echo '<div class="icon-status-author">'.__('Author','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(getUserRoles($author_id)=='editor') { echo '<div class="icon-status-editor">'.__('Editor','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>';}; } } } } }
- add_action(‘asgarosforum_after_post_author’, ‘my_asgarosforum_after_post_administration’, 10, 2);
- function getUserRoles($id) {
- $user = new WP_User((int)$id);
- return implode(‘ and ‘, $user->roles);
- }
- function my_asgarosforum_after_post_administration($author_id, $author_posts) {
- if (getUserRoles($author_id)==‘administrator’) {
- echo ‘<div class=”icon-status-admin”>’.__(‘Admin’,‘rcl-asgaros’).‘ <i class=”fa fa-info-circle”></i></div>’;
- } else {
- if (AsgarosForumPermissions::isModerator($author_id)) {
- echo ‘<div class=”icon-status-moderator”>’.__(‘Moderator’,‘rcl-asgaros’).‘ <i class=”fa fa-info-circle”></i></div>’;
- } else {
- if(getUserRoles($author_id)==‘contributor’) {
- echo ‘<div class=”icon-status-contributor”>’.__(‘Contributor’,‘rcl-asgaros’).‘ <i class=”fa fa-info-circle”></i></div>’;
- } else {
- if(getUserRoles($author_id)==‘author’) {
- echo ‘<div class=”icon-status-author”>’.__(‘Author’,‘rcl-asgaros’).‘ <i class=”fa fa-info-circle”></i></div>’;
- } else {
- if(getUserRoles($author_id)==‘editor’) {
- echo ‘<div class=”icon-status-editor”>’.__(‘Editor’,‘rcl-asgaros’).‘ <i class=”fa fa-info-circle”></i></div>’;};
- }
- }
- }
- }
- }
add_action('asgarosforum_after_post_author', 'my_asgarosforum_after_post_administration', 10, 2); function getUserRoles($id) { $user = new WP_User((int)$id); return implode(' and ', $user->roles); } function my_asgarosforum_after_post_administration($author_id, $author_posts) { if (getUserRoles($author_id)=='administrator') { echo '<div class="icon-status-admin">'.__('Admin','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if (AsgarosForumPermissions::isModerator($author_id)) { echo '<div class="icon-status-moderator">'.__('Moderator','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(getUserRoles($author_id)=='contributor') { echo '<div class="icon-status-contributor">'.__('Contributor','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(getUserRoles($author_id)=='author') { echo '<div class="icon-status-author">'.__('Author','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(getUserRoles($author_id)=='editor') { echo '<div class="icon-status-editor">'.__('Editor','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>';}; } } } } }Names can be changed
Hi
Where exactly is the file functions.php?
Quote from Yworld on January 18, 2017, 6:52 amAdd the the rank to the forum:
- administrator
- moderator
- contributor
- author
- editor
To do this you just have to add this code to your themes functions.php file:
add_action('asgarosforum_after_post_author', 'my_asgarosforum_after_post_administration', 10, 2); function getUserRoles($id) { $user = new WP_User((int)$id); return implode(' and ', $user->roles); } function my_asgarosforum_after_post_administration($author_id, $author_posts) { if (getUserRoles($author_id)=='administrator') { echo '<div class="icon-status-admin">'.__('Admin','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if (AsgarosForumPermissions::isModerator($author_id)) { echo '<div class="icon-status-moderator">'.__('Moderator','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(getUserRoles($author_id)=='contributor') { echo '<div class="icon-status-contributor">'.__('Contributor','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(getUserRoles($author_id)=='author') { echo '<div class="icon-status-author">'.__('Author','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(getUserRoles($author_id)=='editor') { echo '<div class="icon-status-editor">'.__('Editor','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>';}; } } } } }
- add_action(‘asgarosforum_after_post_author’, ‘my_asgarosforum_after_post_administration’, 10, 2);
- function getUserRoles($id) {
- $user = new WP_User((int)$id);
- return implode(‘ and ‘, $user->roles);
- }
- function my_asgarosforum_after_post_administration($author_id, $author_posts) {
- if (getUserRoles($author_id)==‘administrator’) {
- echo ‘<div class=”icon-status-admin”>’.__(‘Admin’,‘rcl-asgaros’).‘ <i class=”fa fa-info-circle”></i></div>’;
- } else {
- if (AsgarosForumPermissions::isModerator($author_id)) {
- echo ‘<div class=”icon-status-moderator”>’.__(‘Moderator’,‘rcl-asgaros’).‘ <i class=”fa fa-info-circle”></i></div>’;
- } else {
- if(getUserRoles($author_id)==‘contributor’) {
- echo ‘<div class=”icon-status-contributor”>’.__(‘Contributor’,‘rcl-asgaros’).‘ <i class=”fa fa-info-circle”></i></div>’;
- } else {
- if(getUserRoles($author_id)==‘author’) {
- echo ‘<div class=”icon-status-author”>’.__(‘Author’,‘rcl-asgaros’).‘ <i class=”fa fa-info-circle”></i></div>’;
- } else {
- if(getUserRoles($author_id)==‘editor’) {
- echo ‘<div class=”icon-status-editor”>’.__(‘Editor’,‘rcl-asgaros’).‘ <i class=”fa fa-info-circle”></i></div>’;};
- }
- }
- }
- }
- }
add_action('asgarosforum_after_post_author', 'my_asgarosforum_after_post_administration', 10, 2); function getUserRoles($id) { $user = new WP_User((int)$id); return implode(' and ', $user->roles); } function my_asgarosforum_after_post_administration($author_id, $author_posts) { if (getUserRoles($author_id)=='administrator') { echo '<div class="icon-status-admin">'.__('Admin','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if (AsgarosForumPermissions::isModerator($author_id)) { echo '<div class="icon-status-moderator">'.__('Moderator','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(getUserRoles($author_id)=='contributor') { echo '<div class="icon-status-contributor">'.__('Contributor','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(getUserRoles($author_id)=='author') { echo '<div class="icon-status-author">'.__('Author','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>'; } else { if(getUserRoles($author_id)=='editor') { echo '<div class="icon-status-editor">'.__('Editor','rcl-asgaros').' <i class="fa fa-info-circle"></i></div>';}; } } } } }Names can be changed
Hi
Where exactly is the file functions.php?
Quote from Asgaros on July 24, 2017, 10:21 pmIts in the folder of the actual WordPress theme which you are using.
Example: wp-content/themes/my-theme/functions.php
Its in the folder of the actual WordPress theme which you are using.
Example: wp-content/themes/my-theme/functions.php
Quote from zydanielson on November 3, 2017, 9:08 amDoes the functions.php file get overwritten when a theme is updated? If so, all the changes made to it have to be made again?
Does the functions.php file get overwritten when a theme is updated? If so, all the changes made to it have to be made again?
Quote from Asgaros on November 3, 2017, 5:00 pmYes, when you update the theme, all changes to it are gone. So the best way is basically to create an own plugin which consists of one file only where you can place all your stuff.
Yes, when you update the theme, all changes to it are gone. So the best way is basically to create an own plugin which consists of one file only where you can place all your stuff.
Quote from sven321 on January 21, 2018, 10:07 pmThe safest is, except for a plugin, ALWAYS a direct backup of the changed files, by date, on an external hdd, something can always happen, logically, also, depending on the amount of data, always an incremental backup.
The safest is, except for a plugin, ALWAYS a direct backup of the changed files, by date, on an external hdd, something can always happen, logically, also, depending on the amount of data, always an incremental backup.
Quote from karmarpgs on October 28, 2018, 1:27 pmQuote from Asgaros on November 3, 2017, 5:00 pmYes, when you update the theme, all changes to it are gone. So the best way is basically to create an own plugin which consists of one file only where you can place all your stuff.
What if you save the code and when you update, upload the saved copy after you have updated it?
Quote from Asgaros on November 3, 2017, 5:00 pmYes, when you update the theme, all changes to it are gone. So the best way is basically to create an own plugin which consists of one file only where you can place all your stuff.
What if you save the code and when you update, upload the saved copy after you have updated it?
Quote from Asgaros on October 29, 2018, 8:09 amHello @karmarpgs
If you update a theme and made changes to its functions.php file before, you should make a backup before and apply your changes again after it.
As an alternative you could create your own plugin-file and add your code there – but this is a little bit advanced for most of the users.
Hello @karmarpgs
If you update a theme and made changes to its functions.php file before, you should make a backup before and apply your changes again after it.
As an alternative you could create your own plugin-file and add your code there – but this is a little bit advanced for most of the users.