1

I have implemented the functionality on flag link click the content are unpublished and click on unflagging the content are published. By using the Rules module.

But this time I want to implement same functionality without using rules module and instead using custom coding.

Any suggestions?

1 Answer 1

2

Any module may react to a piece of content being flagged by implementing hook_flag(). Here is the relevant do so:

mymodule_flag($action, $flag, $content_id, $account) {
  if ($action == 'flag') { // Or $action == 'unflag'.
    // Do something in response to the flagging.
  }

  if ($flag->name == 'yourflagname') {
    //Your custom code to unpublish/publish the content goes here.
  }

}

Source: "Responding to a flagging", located within the Flag's community documentation.

1
  • thanks Pierre, In First condition What Code I am write Publish/unpublish query or another code Apr 1, 2016 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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