Skip to content

Instantly share code, notes, and snippets.

Last active October 21, 2020 00:58
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Using a custom query parameter to dynamically specify a user ID for editing with Advanced Forms Pro.
add_filter( 'af/form/args', 'afp_demo_support_dynamic_user_editing', 10, 2 );
* @param array $args
* @param array $form
* @return array
function afp_demo_support_dynamic_user_editing( $args, $form ) {
// If there is no query arg, return early.
if ( ! isset( $_GET['afp_edit_user'] ) ) {
return $args;
// You should consider adding capability checks here to ensure the
// current logged in user is allowed to edit the requested user.
// Extract the user ID from the custom query arg and add it to the
// form args.
$args['user'] = intval( $_GET['afp_edit_user'] );
return $args;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment