Adding Landscape layer info to landscape material layer

Basically I am importing landscapes from heightmap data in C++ and then assigning a material to the landscape in the same script. But the material doesn’t show on the landscape automatically, I have to manually input the landscape layer info into each material layer in the editor for it to show. Is there a way I’m missing to avoid having to add the landscape layer info manually every time, is there a way to do it in the material or in C++?

Here are a few images from the project to clarify what I mean…
image
image