How to programmatically publish/unpublished node using flag link and without using Rules? 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?
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-&gt;name == 'yourflagname') {
    //Your custom code to unpublish/publish the content goes here.
  }

}


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