I am trying to use a shortcode to display Ultimate Member form, the issue I have is the output of the shortcode always displays at the top of the page and not where I placed the shortcode.
I think its outputting acf_form(settings) as soon as the shortcode is called and not returning it.
function op_profile_skills_func (){
$form = acf_form($settings);
return $form;
}
add_shortcode('op_profile_skills', 'op_profile_skills_func');
Not sure what I am doing wrong, any thoughts? I have tried echo.
As you supposed, the function is printing the form rather than returning it.
What you can do is to capture the output using an output buffer:
function op_profile_skills_func (){
ob_start();
acf_form($settings);
$form = ob_get_clean();
return $form;
}
Everything echoed or printed between start and clean will be collected and passed to $form
.