Skip to:
Content
Pages
Categories
Search
Top
Bottom

PDF Functionality


  • mnctigah
    Participant

    @mnctigah

    I’m new to BuddyPress and am resorting to support forums after some very lengthy internet searches that haven’t been very helpful in providing a solution to my needs.

    I’m running BP 2.3.2.1 on WordPress 4.2.2 on an NGINX VPS.

    I’m trying to add some print to PDF and CSV functionality to a Members Directory page using whatever class or library that will enable me to achieve this (FPDF, mPDF, PDFlib, etc). I would like to print a members list to PDF and export a CSV from the frontend, with or without profile data.

    The plugins available are simply inadequate to achieve. Any help would be appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)

  • Henry Wright
    Moderator

    @henrywright

    Hi @mnctigah

    You should provide details of what exactly you need help with. Choosing a library? Using the library? Troubleshooting the library?


    mnctigah
    Participant

    @mnctigah

    Thanks for the response Henry…

    Let’s go with FPDF for the sake of simplicity. I have that installed on public html and trying to call that function by way of two links placed in a Members Directory page. One link to print the entire directory to PDF with complete profiles, the other link to print the entire directory to PDF without the profile data.

    Where do I “require(‘../fpdf/fpdf.php’);” and where in loop to call from?


    danbp
    Participant

    @danbp


    Henry Wright
    Moderator

    @henrywright

    Where do I “require(‘../fpdf/fpdf.php’);” and where in loop to call from?

    You could place this at the top of your template file. So if you’re using the BuddyPress template hierarchy, that would be your members/index.php template. Be sure to adjust the path, unless of course you have the class stored in the parent directory.


    mnctigah
    Participant

    @mnctigah

    Thanks for the answers.

    Taking it a bit further… I played around with the wpDataTables plugin which allows me to enter SQL queries into an interface and display database info into a table with options to export as PDF or CSV. The problem arises if I use BuddyPress XProfile Data plugin. Serialized array and SQL.

    I also looked at Gravity Forms (with the User Registration Add-On). This handshakes with BuddyPress. GravityView, an additional plugin, allows me to access, extract, and display serialized data from the database, and then generate the desired PDF and CSV Membership Directory. A bit clunky, but then as luck would have it, there are conflicts with my theme (TwentyThirteen). When initially visiting the site, a manual refresh of the page needs to be done in order for GravityView’s search page to display correctly. And then the desired output (PDF + CSV) is garbled. TwentyThirteen is the only theme it will do it on. I’ve tried a CSS reset in the core css files to no avail. I’m running a TwentyThirteen child theme with a separate BP stack.

    So this brings me to a PHP solution for which I’m sketchy. I could either do some sort of cron job periodically and unserialize the xprofile data and insert it into a new table. That would let me access it via SQL Query and the original wpDataTables plugin. This would peridocially update any new additions to my BuddyPress Membership into an unserialized table.

    The better solution is to do it all with PHP. I now have the FPDF class up and running. I’m generating sample PDF output. So from my PHP script, I’m “requiring” fpdf.php and also an “include” for another php file to open a connection to MySQL.

    Now I’m to the point where I need info and help as to construct the code and read serialized data into my newly created file to generate the PDF (i.e. “sql2pdf.php).

    Thanks in advance.


    Henry Wright
    Moderator

    @henrywright

    This doesn’t answer your question but you say you’re including a file to open a mysql connection. Interacting with the WordPress database should be done though the wpdb class. Check it out, it’ll make your life easier and ensure your code is secure.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘PDF Functionality’ is closed to new replies.
Skip to toolbar