Ajouter une colonne personnalisée au panneau d'administration des utilisateurs
-
-
Avez-vous configuré lenuméro detéléphone?Je veux dire,votre utilisateurpeut-il ajouter desnuméros detéléphone dans sonprofil?Do you have phone number setup? I mean can your user add phone numbers in their profile?
- 0
- 2014-09-06
- Robert hue
-
non ..je veuxjuste savoir comment ajouter .. cen'estpas corriger cenuméro de contact seulement ..ilpeutb juste une colonne vide aussino .. I just want to know how to add .. its not fix that contact number only .. its can b just a blank column also
- 0
- 2014-09-06
- Rohil_PHPBeginner
-
Si votre site abeaucoup de colonnespersonnalisées,vouspourriez êtreintéressépar unplugin appelé Admin Columns.If your site had a lot of custom columns, you might be interested in a plugin called Admin Columns.
- 1
- 2016-06-01
- somebodysomewhere
-
vouspouvez voir ceblog avec desexplications détaillées http://tekina.info/add-extra-column-user-listing-page-wordpress-admin-panel/you can see this blog with detailed explanation http://tekina.info/add-extra-column-user-listing-page-wordpress-admin-panel/
- 0
- 2017-09-12
- Aniket Singh
-
Pour lesnon-codeurs,ilexiste unplugin [Advanced Custom Fields] (https://www.advancedcustomfields.com/).(Googlemène également à cettepage. Les débutantsne connaissentpeut-êtrepastous lesplugins de WordPress)For the non-coders, there is a plugin [Advanced Custom Fields](https://www.advancedcustomfields.com/). (Google leads to this page, too. Newbies might not know all plugins of WordPress)
- 0
- 2020-07-12
- koppor
-
1 réponses
- votes
-
- 2014-09-06
OK,voici le codepermettant à vos utilisateurs d'ajouter desnuméros detéléphone. Collez ce code complet dans lefichierfunctions.php. Cela ajoutera unnouveau champ sur leprofil utilisateurpour "Numéro detéléphone"et ajoutera unetable utilisateur de colonne sur l'administrateur WordPresspourtéléphone.
function new_contact_methods( $contactmethods ) { $contactmethods['phone'] = 'Phone Number'; return $contactmethods; } add_filter( 'user_contactmethods', 'new_contact_methods', 10, 1 ); function new_modify_user_table( $column ) { $column['phone'] = 'Phone'; return $column; } add_filter( 'manage_users_columns', 'new_modify_user_table' ); function new_modify_user_table_row( $val, $column_name, $user_id ) { switch ($column_name) { case 'phone' : return get_the_author_meta( 'phone', $user_id ); default: } return $val; } add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );
< EDIT
Pour ajouter deux colonnes,vous devez apporter desmodifications. Comparez les deux codespour comprendre.
function new_modify_user_table( $column ) { $column['phone'] = 'Phone'; $column['xyz'] = 'XYZ'; return $column; } add_filter( 'manage_users_columns', 'new_modify_user_table' ); function new_modify_user_table_row( $val, $column_name, $user_id ) { switch ($column_name) { case 'phone' : return get_the_author_meta( 'phone', $user_id ); case 'xyz' : return ''; default: } return $val; } add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );
Ok, Here is the code to allow your users to add phone numbers. Paste this full code in functions.php file. This will add new field on user profile for "Phone Number" and add a column user table on WordPress admin for phone.
function new_contact_methods( $contactmethods ) { $contactmethods['phone'] = 'Phone Number'; return $contactmethods; } add_filter( 'user_contactmethods', 'new_contact_methods', 10, 1 ); function new_modify_user_table( $column ) { $column['phone'] = 'Phone'; return $column; } add_filter( 'manage_users_columns', 'new_modify_user_table' ); function new_modify_user_table_row( $val, $column_name, $user_id ) { switch ($column_name) { case 'phone' : return get_the_author_meta( 'phone', $user_id ); default: } return $val; } add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );
EDIT
To add two columns you need to make some changes. Compare both codes to understand.
function new_modify_user_table( $column ) { $column['phone'] = 'Phone'; $column['xyz'] = 'XYZ'; return $column; } add_filter( 'manage_users_columns', 'new_modify_user_table' ); function new_modify_user_table_row( $val, $column_name, $user_id ) { switch ($column_name) { case 'phone' : return get_the_author_meta( 'phone', $user_id ); case 'xyz' : return ''; default: } return $val; } add_filter( 'manage_users_custom_column', 'new_modify_user_table_row', 10, 3 );
-
Utilisez ànouveau le code.Je l'ai changépour que vouspuissiez également voir le champ detéléphone sur la liste des utilisateurs.Use code again. I changed it so you can see phone field on user list too.
- 0
- 2014-09-06
- Robert hue
-
Génial!travaillé .. Mais aumoment de l'ajout d'un utilisateur,pourquoine demandent-ilspas denuméro detéléphone?Great! worked .. But at the time of adding user why are they not asking for Phone Number ?
- 0
- 2014-09-06
- Rohil_PHPBeginner
-
Pouvez-vousexpliquer ce code?Je veux ajouter un autre champmaisilme montre uneerreur.Can you please explain this code ? I want to add one more field but it is showing me an error.
- 0
- 2014-09-06
- Rohil_PHPBeginner
-
Vérifiez lesmodifications dans le code ci-dessus.Vouspouvez ajouter autant de colonnes que vous le souhaitez.Check edits in above code. You can add as many columns as you want.
- 0
- 2014-09-06
- Robert hue
-
Je suggérerais que cela soit ajouté à un [plugin spécifique au site] (http://ottopress.com/2011/creating-a-site-specific-snippets-plugin/) car celan'a rien à voir avec l'apparence duthème.I would suggest this be added to a [site-specific plugin](http://ottopress.com/2011/creating-a-site-specific-snippets-plugin/) since it has nothing to do with the theme's appearance.
- 2
- 2014-09-06
- helgatheviking
-
merci Robert .. vousm'avezbeaucoup aidé !! pouvez-vousme dire la dernière chose ... qu'est-ce que 10et 3 dans la dernière ligne du code ..thanks Robert .. you helped me a lot !! can you just tell me last thing .. what is 10 & 3 in the last line of the code ..
- 0
- 2014-09-06
- Rohil_PHPBeginner
-
C'est des argumentsprioritaireset acceptés.Consultez la documentation sur add_filterici,http://codex.wordpress.org/Function_Reference/add_filterThat is priority and accepted args. Check docs on add_filter here, http://codex.wordpress.org/Function_Reference/add_filter
- 0
- 2014-09-06
- Robert hue
-
S'il s'agit d'unthème commercial (gratuit oupayant),veuillezne pasmettre ce code dansfunctions.php duthème.Parce que vouspouvezperdre cesmodifications si lethèmeestmis àjour.Créez unpetit pluginpour cela.If it is a commercial (free or paid) theme then please don't put this code in theme's functions.php. Because, you can lose these changes if theme is updated. Make a small plugin for this.
- 1
- 2015-04-27
- Omar Tariq
-
quelest le retour de $?what's the $return?
- 0
- 2016-02-04
- Mateusz Bartkowski
-
Oui,pourquoiil y a un «return $ return» à lafin,s'il vousplaît?pouvez-vous l'expliquer?Yes why there is a `return $return` at the end, please? could you explain it?
- 0
- 2016-03-30
- LoicTheAztec
-
Enfin,`$ user=get_userdata ($ user_id);`et `return $ return`ne sont absolument **pas **nécessaires.La variable «$ user»n'estpas utiliséepar lafonctionet «$ return»n'estpas définie doncellene renvoie rien.Finally `$user = get_userdata( $user_id );` and `return $return` are absolutely **not** necessary. Variable `$user` is not used by the function and `$return` is not defined so it is returning nothing.
- 1
- 2016-03-30
- LoicTheAztec
-
hé @Robert huemercipour le code detravail.J'ai une question.Jene voispas cette colonne dansmatable DB wp_users.Pourquoi?hey @Robert hue thanks for the working code. I have one question. I don't see this column in my DB wp_users table. Why?
- 1
- 2016-05-03
- Anahit DEV
-
Jen'obtiens rien de cettefonctionnew_modify_user_table_row ($ val,$nom de colonne,$ user_id),pouvez-vousme direpourquoi?I am getting nothing from in this fucntion new_modify_user_table_row( $val, $column_name, $user_id ) , Can you please let me know why?
- 0
- 2016-05-27
- Deepak saini
-
@Roberthueexiste-t-il unmoyen de réorganiser la colonne?@Roberthue is there a way to re-order the column?
- 0
- 2016-06-08
- JohnnyQ
-
ah l'atrouvé [ici] (http://codepixelz.com/web-design/how-to-add-new-column-on-user-listing-of-wordpress-dashboard/).ah found it [here](http://codepixelz.com/web-design/how-to-add-new-column-on-user-listing-of-wordpress-dashboard/).
- 0
- 2016-06-08
- JohnnyQ
-
Vraimentpointilleuxmaisnousn'avonsprobablementpasbesoin de lapause;commenousfaisons un retour sur les lignes ci-dessus.Merci d'avoirposté - vraiment aidé.Really nitpicky but we probably don't need the break; as we are doing a return on the lines above. Thanks for posting though - really helped.
- 0
- 2017-10-11
- Daniel Casserly
Il y a 5 colonnespar défautnommées Nom d'utilisateur Nom E-mail Rôle Posts dans USERS. Maintenant,je veux ajouter une colonne supplémentaire avec sonnuméro de contact.
Commentpuis-je yparvenir??