Skip to content

Instantly share code, notes, and snippets.

@xnau
Last active April 19, 2017 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xnau/467c78f5711035a527ae914a3256381b to your computer and use it in GitHub Desktop.
Save xnau/467c78f5711035a527ae914a3256381b to your computer and use it in GitHub Desktop.
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