您没有说明如何实现代码:如果您使用的是页面模板或自定义贴子页面,您可以这样做:
<?php
$user_id = get_current_user_id();
if ($user_id == 0) {
echo \'You are currently not logged in.\';
} else {
echo do_shortcode(\'[pods-form name="user" id="\'.$user_id.\'" fields="my_field, my_field_2, my_field_3"]\');
}
?>
您是否希望在内容之后或之前在所有页面上添加此内容,您可以将其添加到功能中。php
function 247070_before_after($content) {
$user_id = get_current_user_id();
if ($user_id == 0) {
$formstatement = \'You are currently not logged in.\';
} else {
$formstatement = do_shortcode(\'[pods-form name="user" id="\'.$user_id.\'" fields="my_field, my_field_2, my_field_3"]\');
}
$addlcontent = $formstatement;
$fullcontent = $content . $addlcontent; //move $addlcontent in front of $content to add your from to the front.
return $fullcontent;
}
add_filter(\'the_content\', \'247070_before_after\');