'Create Url based on User's First and Last names
I'm trying to generate a link based on a user's first and last name to display on their archive page. I currently have the link set to a custom field called "archive_link" and am using the acf update_value hook to update the field. (BTW I'm using a text field instead of a url because it plays more nicely with Elementor's dynamic fields.)
function my_acf_update_value( $value, $post_id, $field, $original ) {
if( is_string($value) ) {
$new_user = get_userdata( $user_id );
# Get the user's first and last name
$first_name = $new_user->first_name;
$last_name = $new_user->last_name;
# Set Archive Link
$value = 'Test' . $first_name . $last_name;
}
return $value;
}
// Apply to all fields.
add_filter('acf/update_value/name=archive_link', 'my_acf_update_value', 10, 4);
Thank you for any help you can offer me with this!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
