Set Rabbit-Hole values for a node programmatically

Created on 15 February 2022, over 2 years ago
Updated 26 June 2023, about 1 year ago

Problem/Motivation

Is it possible to update Rabbit-Hole values for a node programmatically?

function my_hook_cron() {
  $some_rh_service->update_rh($my_node, 'content_not_found');
}
πŸ’¬ Support request
Status

Closed: won't fix

Version

1.0

Component

Documentation

Created by

πŸ‡©πŸ‡ͺGermany dotist

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡¦Ukraine Matroskeen πŸ‡ΊπŸ‡¦ Ukraine, Lutsk

    This is correct answer.

    8.x-1.x version:

    $entity->set('rh_action', 'page_redirect');
    $entity->set('rh_redirect', 'https://savelife.in.ua/en/');
    $entity->set('rh_redirect_response', 307);
    $entity->set('rh_redirect_fallback_action', 'access_denied')
    

    2.0.x version:

    $entity->set('rabbit_hole__settings', [
      'action' => 'page_redirect',
      'settings' => [
        'redirect' => 'https://savelife.in.ua/en/',
        'redirect_code' => 307,
        'redirect_fallback_action' => 'access_denied',
      ],
    ]);
    
Production build 0.69.0 2024