Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
illustrates how to set up the record edit shortcode based on the current user
<?php
/*
* this code assumes that there is some value in the participant's record that
* determines what groups they will have access to
*/
$pid = filter_input( INPUT_GET, 'pid', FILTER_SANITIZE_STRING );
$id = Participants_Db::get_participant_id( $pid );
if ( $id ) :
$user_record = Participants_Db::get_participant( $id );
// change this to use whatever value it is you need to determine what groups to show
// we are using 'student' and 'teacher' as examples of types of participant
switch ( $user_record['type'] ) {
case 'student':
$groups = 'main,address,student_info';
break;
case 'teacher':
$groups = 'main,address,teacher_info';
break;
}
// now show the record edit form for the current participant:
echo do_shortcode( '[pdb_record record_id=' . $id . ' groups=' . $groups . ']' );
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment