Created
June 2, 2021 23:13
-
-
Save mattneal-stafflink/9bb575a23d6039ca26e2b88ea6a9b829 to your computer and use it in GitHub Desktop.
Display the user goals form on the front end using a shortcode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Display the user goals form on the front end using a shortcode. | |
* | |
* @since 1.0.0 | |
*/ | |
function stafflink_user_goals( $atts ) { | |
$a = shortcode_atts( array( | |
'field_group' => '' | |
), $atts ); | |
$uid = get_current_user_id(); | |
if ( ! empty ( $a['field_group'] ) && ! empty ( $uid ) ) { | |
$options = array( | |
'post_id' => 'user_'.$uid, | |
'field_groups' => array( intval( $a['field_group'] ) ), | |
'return' => add_query_arg( 'updated', 'true', get_permalink() ) | |
); | |
ob_start(); | |
acf_form( $options ); | |
$form = ob_get_contents(); | |
ob_end_clean(); | |
} | |
return $form; | |
} | |
add_shortcode( 'stafflink_user_goals', 'stafflink_user_goals' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment