What function child site uses when mainwp admin publish post?

I am trying to write a plugin but failing. tried to hook “wp_insert_post” failed tried “publish_post” failed.

it is weird.

do you guys publish the post directly to database with custom function?
is there hook I can hook at for my plugin?

what I am trying to do do is make some changes or edits after the mainwp admin publishes on the child site. I am going to install the plugin on the child site.

please point me to the right path for what class and what function is used I can handle the rest hopefully.

@sinanisler Here is a list of Post hooks that you may tap into with your extension code:

In order to communicate with a child site through MainWP, you will want to put your MainWP Extension on the MainWP Installation - not the Child Site. If you put it on the child site you will need to build a second plugin to extend the MainWP Child Plugin.

MainWP Development Resources: MainWP.dev

2 Likes

plugin needs to be in the child site

I need to make some edits and changes in child site after the post gets published on the child site.

I checked this actions they all related to the main admin site.

I need child site actions.
after post saved as draft or published I need to fire action in the child site right after that.

if this mainwp_after_post_action action was in child site it would have solved my problem but there is no action like that in child plugin.

@sinanisler All post methods are handled within this Class on the MainWP Child Plugin:

I still think you are going about this the wrong way. My reasoning is, the whole Idea behind MainWP is to not need another plugin installed on the Child Site to perform tasks from the MainWP Dashboard, unless it’s controlling a 3rd-party “plugin” ( I may still be wrong ) - I am in contact with the rest of the Dev Team & I will post our suggestions once I have a definitive answer with how you should proceed.

Thanks for your patience :slight_smile:

2 Likes

nope that wont do I am pretty sure.

client publishing multiple post on multiple site same time BUT they want to have different categories on each post/site. :upside_down_face:

right now this is impossible with the mainwp. :blush:

found a solution I am verifying each sites category and locking them with meta and checking if the category is new or not. easy.
I decided to use init action. ugly but it works. I will optimize later maybe :rofl:

@sinanisler I am probably just confused on the “Post Flow” that you are trying to achieve. I will still post our suggestions here once I have something tangible.

If you could describe the "Start to finish" of what you are trying to accomplish with your custom code it will give us a better idea of what exactly you are trying to achieve so that we can suggest the best options you may choose from if & when you plan your “optimization” phase of your project. ( If you don’t want to explain in public fee free to DM me )

1 Like

well I did on top of the post let me try again

feature / core: publishing multiple post on multiple site but selecting different categories for each site. some categories doesn’t exist on other site each site has its own categories.

as you know right now when we publishing posts if we don’t check this checkmark and mainwp will constantly add new categories to the other sites if the selected category doesn’t exist on the child site.

image

lets say I picked the cat1 for site1 and cat5 for site2

site1
cat1
cat2

site2
cat4
cat5

in this situation after I press publish cat4 will be added on site1 and cat1 will be added to site2 :slight_smile:

this is the problem I just solved :slight_smile:

you guys implemented a simple solution like just check this right?
image

but if the client do that none of the post will be published on any site because there is no category there because they are different sites and each site has different categories :wink:

2 Likes

@sinanisler When testing your First Scenario ( if cat4 is a typo and is really cat5 ) you are correct. If post only to existing categories unchecked, cat1 & cat5 are selected & both sites are selected - MainWP will create the cat1 & cat5 categories if they are not there before posting.


When testing your Second Scenario - when publishing posts that don’t have a specific Category, they are posted to the “Uncategorized” category as in this screenshot. So I am not sure why your version doesn’t post - but that’s not the expected default behavior.

Needless to say, since you already have a solution for your case - I am going to chalk this thread up as “SOLVED”. If we run into a better solution for this case we will be sure to update this thread for you and the community :slight_smile:

1 Like

dream solution would be this;

image

consider it.

yes you can mark solved its fine.

1 Like

@sinanisler We are always up for suggestions! Please feel free to make a feedback request if you would like to so other may vote on it. feedback.mainwp.com

2 Likes

this doesnt count as a suggestion or even a feature really. it is ux core problem that needs to be solved.
I am lucky I coded something and solved it myself but others will have no idea what is happening.

have a great weekend :slight_smile:

1 Like

I was using your nomenclature.

Thanks. you as well! :grinning:

2 Likes