Support » Plugin: Co-Authors Plus » When changing or adding an author, change it on other custom post type.

  • Cédric Charles

    (@cedriccharles)


    Hi !

    First of all, thank you for you great plugin. I have a special need…

    On my website, registered users can create a company (CPT “companies”). When they have created their company, users can create news/projects/events/jobs. When they post that kind of posts, the post is saved with a custom field that contains the id of the company created by this author.

    For example, I create a company with ID=12. Then I create a project. When I publish this project, WP add a custom field to it : company_ID=12.

    Everything goes well for this part.

    Now, I’ve installed your plugin because more than one user can manage a company. This part goes well too. But…
    When I add/change/remove a company’s author, I need the process to be repeated on each custom post type for which the custom field company_id is equal to the ID of the company.

    Do you understand ?
    Thank you very much for your help !

    Cédric

    http://wordpress.org/extend/plugins/co-authors-plus/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Cédric Charles

    (@cedriccharles)

    After thinking, I know the process but not the code…

    I have to grab any change of authors in my ‘companies’ post type… Could you help ?

    Plugin Author Mohammad Jangda

    (@batmoo)

    This isn’t super easy to do but is possible.

    You can hook into save_post, and if the author(s) have changed, fetch all object associated with the company (via a meta_query) and use the $coauthors_plus->add_coauthors method to update the authors for these objects.

    That’s obviously very high level but hopefully enough to get you started.

    Plugin Author Mohammad Jangda

    (@batmoo)

    Also, if this is for a private site, you may want to consider using the Posts2Posts plugin for handling the relationships between company and objects.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘When changing or adding an author, change it on other custom post type.’ is closed to new replies.