I'm trying to allow users to export their own profile info to a CSV using a link on their profile. Everything works except the $url path of the link. Here's what I have:

$url = $_GET['uri'];
$nonce = wp_create_nonce( 'download_csv' );
return '<a href="'. $url. '&action=download_csv_bc&_wpnonce='. $nonce.'" class="page-title-action">Export to CSV</a>';

This outputs "https://myurl.com/user/username/&action=download_csv_bc&_wpnonce=3a9caf44cb" and results in a Page Not Found when clicked.

I can successfully export data from my plugin in the admin area with the following path just fine:

$url = admin_url( 'admin.php?page=myplugin-settings-page' );

But now that I'm trying to export from the front end I'm having issues. I have also tried the following examples which doesn't work either:

$url = admin_url( 'users.php' );
$url = admin_url( 'profile.php' );

(Not sure if it matters, but I am using Ultimate Member for profiles.)

  • have you tried with this <?php echo esc_url( get_avatar_url( $user->ID ) ); ?> – Gopala krishnan Dec 3 '19 at 5:23
  • Just tried. It just shows me their profile picture. :( – Mr Gandy Dec 3 '19 at 14:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.