• Resolved supernova42

    (@supernova42)


    I’m trying to use the shortcode [pdb_single] to allow a user to display their information.

    If the users Record Info is id = 152 and Private_id = H7J9J

    I can use [pdb_single record_id=152] and that will display a users information. But I would like this to work for all users.

    I’ve tried [pdb_single record_id=id] and probably every combination but I cannot get it to display a users information.

    I know that I can use something like https://website.com/members/?pid=H7J9J which works fine but is not practical.

    What do I need to put inside my shortcode in order to get is to display a users information.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author xnau webdesign

    (@xnau)

    Normally, this is done automatically by the plugin when you set up your list. Take a look at the “Setup Guide” in the Participants Database admin menu, it explains how to set up the “Single Record Link” in the list.

    If you want to show a link to an editable record, take a look at this article:

    Adding an Edit Record Link to the Frontend List

    Thread Starter supernova42

    (@supernova42)

    I have previously created a list of members with a ‘Single Record Link’ that takes the user to a specific record for viewing and it works fine.

    However what I want to do know is for the user to just view their own single record. I can view the record with [pdb_single record_id=152] but I want to replace the record_id with a parameter so that all users can see their own individual records.

    I imported all my data into Participants Database and not sure if that might be causing a proble.

    Thanks

    Plugin Author xnau webdesign

    (@xnau)

    What you need to do is use the logged-in user’s info (such as their user ID) to find their record ID in Participants Database. Once you have the their record ID, you can show them their record using some php:

    <?php echo do_shortcode(‘[pdb_single record_id=’ . $pdb_record_id . ‘]’); ?>

    Take a look at this article for more on how this can be done:

    Using Participants Database with WordPress Users

    Thread Starter supernova42

    (@supernova42)

    I have almost solved this problem. I have copied the WP username to the PD username so that I have a link.

    I can then user the WP command wp_get_current_user() which works fine and I can print out the current users username.

    If I want to search and list the current users record (JIMMY) I can user the filter=”username=JIMMY”.

    That works fine however when I use the filter=”username=” . $user_name it just doesn’t work – it lists ALL the records. What am I doing wrong with the filter command.

    [insert_php]
    $current_user = wp_get_current_user();
    $user_name=$current_user->user_login;
    echo do_shortcode(‘[pdb_list filter=”username=”.$user_name fields=”username,first_name,last_name”]’);
    [/insert_php]

    Many Thanks for your Help…

    Plugin Author xnau webdesign

    (@xnau)

    Check your quotes in the do_shortcode func….looks like you got a couple mixed up.

    Thread Starter supernova42

    (@supernova42)

    Right I’ve got it. The wp_get_current_user() was the function I needed and of course you one needs to get the inverted comma’s in the right place

    [insert_php]
    $current_user=wp_get_current_user();
    $users_name=$current_user->user_login;
    echo do_shortcode(‘[pdb_list filter=”username=’.$users_name.'” fields=”title,first_name,last_name,address_1,city”]’);
    [/insert_php]

    Many thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Displaying User Fields’ is closed to new replies.