How to create admin page but so that I can pass a GET variable to it?

[ad_1]

How can I create admin page where I can pass GET variable?
This page works, its URL is http://localhost/web/wp-admin/admin.php?page=osobe-stranica

But I can’t pass a variable to it like this http://localhost/web/wp-admin/admin.php?page=osobe-stranica?user_id=10 cause I get “Sorry, you are not allowed to access this page.” I am admin.

add_menu_page(
‘Osobe’,
‘Osobe’,
‘manage_options’,
‘osobe-stranica’,
‘prikazi_osobe_stranicu’,
‘dashicons-admin-users’,
1
);

function prikazi_osobe_stranicu() {
var_dump($_GET);
}

I’ve tried this already:

add_filter( ‘query_vars’, ‘dodaj_user_id_query_var’ );
function dodaj_user_id_query_var( $vars ) {
$vars[] = ‘user_id’;
return $vars;
}

[ad_2]
1 Comment
  1. It’s already passing a parameter. ?someparam=something&someotherparam=something the issue is you haven’t accounted for the existing. Param, and then used an improper character. Use & instead where a param already exists.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer