Come together with the global Drupal community in Rotterdam, 28 Sept – 1 Oct 2026. Sessions, contribution, connection, and Early Bird savings until 8 June.
This is fine, but what happens if the author is not a user of the site? Do I have 2 fields for the author, one of they are a member, and another if they are not.
one idea might be that for Drupal users, you could store their numerical ID (users.uid), and for non-user authors, you could store text, both in the same field
then your code could do different things with the authors depending on whether it found/was supplied a number/text for the author field
in the entry GUI, you could provide an option like two radio buttons and a text field:
o make me the author (which would put the current user's uid in your author field)
o relate to new author: ____________________ (which would put the user supplied author name in your author field)
in the display GUI, you could display:
if there's a number in the author field that corresponds to a number in users.uid: the author info from that user's record in users table
if there's text in the author field: just display it
one issue would be you'd have to make your field a char/text type, while users.uid is an integer field, but you could tranform your value to an integer in your code when dealing with the users table
Comments
Comment #1
gordon commentedThis is fine, but what happens if the author is not a user of the site? Do I have 2 fields for the author, one of they are a member, and another if they are not.
Comment #2
xolotl commentedone idea might be that for Drupal users, you could store their numerical ID (users.uid), and for non-user authors, you could store text, both in the same field
then your code could do different things with the authors depending on whether it found/was supplied a number/text for the author field
in the entry GUI, you could provide an option like two radio buttons and a text field:
o make me the author (which would put the current user's uid in your author field)
o relate to new author: ____________________ (which would put the user supplied author name in your author field)
in the display GUI, you could display:
if there's a number in the author field that corresponds to a number in users.uid: the author info from that user's record in users table
if there's text in the author field: just display it
one issue would be you'd have to make your field a char/text type, while users.uid is an integer field, but you could tranform your value to an integer in your code when dealing with the users table