Shortcode/ merge tag for default value


I have a custom shortcode that I would like to use for the default value for a field, but I just can’t get it to work.

I’ve defined the shortcode as follows:

add_shortcode('mb-user-role', function() {
  global $wp_roles;
  if( is_user_logged_in() ) {
    $user = wp_get_current_user();
    $roles = ( array ) $user->roles;
    echo '<ul>';
    foreach( $roles as $role ){
      echo '<li>' . $wp_roles->roles[ $role ]['name'] . '</li>';
    echo '</ul>';

This works when I used it in a post as [mb-user-role], but when I use it as the default value specified as “[mb0user-role]” (No quotes) all I see is [test-name] when I view the form, I know i can use ‘gform_replace_merge_tags’ and use a merge tag instead but i Just can’t seem to figure how to write the function.

Can you help me with that?