Last active
April 19, 2017 19:54
-
-
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
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 | |
/* | |
* 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