WordPress.org

Ready to get started?Download WordPress

Forums

Co-Authors Plus
When changing or adding an author, change it on other custom post type. (4 posts)

  1. cedric.charles
    Member
    Posted 1 year ago #

    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/

  2. cedric.charles
    Member
    Posted 1 year ago #

    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 ?

  3. Mohammad Jangda
    Member
    Plugin Author

    Posted 11 months ago #

    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.

  4. Mohammad Jangda
    Member
    Plugin Author

    Posted 11 months ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.