0

I have been able to use the Advance Custom Fields plugin to create more fields I need for every new user to our site. What we need though, is that once someone has registered, they still need to be able to print off their details, sign it and bring it back to the property agency.

What I need is to be able to add a print button next to the Update User button which would then pull all the details of that person, lay it out nicely and export it as a PDF for that person to sign and bring back.

Here is what I would consider:

  • Create new plugin
  • Look into get_userdata() function to pull details.
  • Figure out how to hook into User page and add button
  • Add event to button that passes User ID to function.
  • Launch Modal window with content extracted.
  • Add button to modal window to print content.

Might not even need the PDF option?

Many thanks

4
  • What is your question exactly? Plugin recommendations are off-topic, please read wordpress.stackexchange.com/help
    – Wyck
    Commented Nov 2, 2013 at 17:04
  • Didn't ask for a plugin recommendation. This was my question "What I need is to be able to add a print button next to the Update User button which would then pull all the details of that person, lay it out nicely and export it as a PDF for that person to sign and bring back." Commented Nov 4, 2013 at 14:10
  • "Do my work for me questions" are also off-topic, your expected to show users what you have tried, please read the wordpress.stackexchange.com/help
    – Wyck
    Commented Nov 4, 2013 at 14:57
  • Perhaps all my other posts show that in most cases I have done research prior to asking the question but if I honestly don't know where to begin, I will at least lay the foundation to my thinking and then take it from there. Commented Nov 6, 2013 at 9:09

2 Answers 2

2

Your question seems pretty specific to your situation, and while there might be a plug-in out there that can achieve what you're looking for, it probably won't fill all your needs without some hackery.

So, have you considered creating a profile view on the front end and just setting up a print stylesheet for it?

You could pass the user's ID to the page as a $_GET variable, or your could set up some custom rewrite rules so the URL is prettier (something like example.com/profile/1234, where 1234 is the user's ID). You could also set up the page to just adapt based on get_currentuserinfo(), but if you ever needed to print off a user's page for your own purposes it wouldn't be as easy, unless you provided an override where if a user_id was passed to the page it would pull up that user's information and if a user_id wasn't provided, it pulled up the currently logged in user's information.

Then you should be able to pull in all the fields using ACF's the_field() method with the user's ID, I'm not sure if ACF has a method that will pull in all of the fields at once, but you could also create your own $wpdb query to grab all the info you need for the user or use the get_userdata() method.

You could also redirect the user to their profile after they register by tying into the user_register action and using wp_redirect() to redirect the newly registered user to the profile so that they can print it.

For the print button you can use the window.print() method, or just rely on the user clicking print (the print stylesheet should take effect either way).

If you are interested in PDF generation, you can use the FPDF class to generate one, but, as far as I know, the user will have to download/open the file and then print it.

As a sidenote: if you are only looking to generate the PDF for printing purposes, providing a print stylesheet is probably an easier solution, as most people can generate a PDF from the print options for their browser and implementing a print stylesheet is generally much simpler than integrating a PDF generation library.

1
  • Thanks Allen, some great points to consider which I will mash up with Josh's. Will get back to you later when I have tried it ;) Commented Nov 3, 2013 at 4:55
1

Your question interested me a bit. I haven't attempted to print profile fields before; but I could certainly see it's uses.

So:

Other than try to explain everything involved; I have made a simple plugin on GitHub.

Simply follow the installation instructions; and it will provide you with a basic template for further modifications, if you like. It can certainly be developed further.

Hope it works for you. Take care!

1
  • Sounds great! Lemme know how it works; or if you have any questions.
    – josh
    Commented Nov 3, 2013 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.