I want to customize the link text, don't want to use string overrides module for this small job.

In my template_preprocess_node() function I tried to change the #title element of the render array. But it doesn't change the link. Any ideas?

//change the "subscribe link for tribes
if ($variables['type'] == 'tribe'){
    if (isset($variables['elements']['group_group']['0']['#title'])){
        $variables['elements']['group_group']['0']['#title'] = 'Join this Tribe';
  • ok, when I use print_r I can see that there are 2 #tribe fields in the array. Is there a better way of finding it other than clicking each option in the dpm() output. When I use print_r() I find it but can't make out the path. – uwe Apr 12 '12 at 2:22
  • 2
    found it, it was $variables['content']['group_group']['0']['#title'] = 'Join this Tribe'; I posted another question about finding elements in the render array: drupal.stackexchange.com/questions/28109/… – uwe Apr 12 '12 at 4:06

You don't necessarily need to use the string overrides module. You can add string overrides directly in your settings.php:

$conf['locale_custom_strings_en'][''] = array(
  'Subscribe to group' => 'Join this Tribe'

For more information, refer to this page in the docs: https://www.drupal.org/node/522036

  • thanks. I prefer to keep stuff like that in a template or module file rather than in the settings – uwe Apr 12 '12 at 4:08

I just figured this out.

In Drupal 7 after you've added the Group Content Visibility to the Organic Group Field Settings (admin/config/group/fields) for the bundle of the content type you're wanting to change this within then you simply go to Manage Fields for that content type and Edit the Field where you can change the Title as well as the language in the options.

In my case I made the title "Share with" and the allowed values list to:

1|Public - visible to all site users 2|Private - visible to only my followers

  • Does that also apply to the "Subscribe to group" link text? Which field do you need to edit there? I can't find any. – Turion Jul 31 '13 at 22:53

If you don't want to change code, the stringoverrides module does a great job. Install it, enable it, go to configuration -> string overrides and add a new line with 'subscribe to group' and 'Join this Tribe'.


I ran into this problem just now. It looks like the best way to determine which message is being displayed to the user is by the class name applied to the output. I found five distinct messages that can be displayed to the end user in the og_ui_field_formatter_view function and decided to replace them all. I also decided to unset all the element title attributes, instead of updating the duplicate text in each title attribute.

function MODULE_preprocess_node(&$variables) {
  if ($variables['type'] == 'NODE TYPE') {
    $field_value = &$variables['content']['group_group'][0];
    $is_link = $field_value['#type'] == 'link';
    $class = $is_link ?
      reset($field_value['#options']['attributes']['class']) :
    switch ($class) {
      case 'group subscribe':
        $field_value['#title'] = t('I am an employee here');
      case 'group unsubscribe':
        $field_value['#title'] = t('I no longer work for this company');
      case 'group other':
        $field_value['#value'] = t('You are already subscribed to other groups');
      case 'group closed':
        $field_value['#value'] = t('This is a closed listing. Only an administrator can add you.');
      case 'group manager':
        $field_value['#value'] = t('This is my company');

You can use this code to check if current user is subscribed to group and check link text according to that.

if (module_exists('og')) {
  if (og_is_member('node', $variables['nid'])) {
    // We do not alter "You are the group manager" text.
    // Assuming that group admin will only have permission to administer group.
    if (!og_user_access('node', $variables['nid'], 'administer group')) {
      $variables['content']['group_group'][0]['#title'] = t('Leave this group');
  else {
    $variables['content']['group_group'][0]['#title'] = t('Join this group');

Write this code in template_preprocess_node(). This code snippet works for Drupal 7.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.