• Resolved elitevacations

    (@elitevacations)


    I have added a custom field with the title of User Login, show it as hidden and added the default data as current_user->user_login. I have set the field to appear in the Sign Up form. I have set the sign up form as available only to logged in users.

    I am using the XYZ Php Code snippets plug in referred to by another user above and pasted the php code as shown in the above instructions of:
    [insert_php]
    $current_user = wp_get_current_user();
    echo do_shortcode(‘[[pdb_list filter=”user_login=’ . $current_user->user_login . ‘”]]’);
    [/insert_php]
    I have pasted that code without the [insert_php] opening and closing tags.
    The snippet is active.

    I have used the signup page to create 2 new users and added differing details to each. I have checked the PD and see that each user now has their WP username inserted in their record in the User Login field.

    All looks good so far.

    I have created a page, that is also only accessible when a user is logged in where I would like users to view their own entry. I have pasted in the filter of [pdb_list filter=”user_login=’ . $current_user->user_login . ‘”] on that page.

    When a logged in user visits that page they have a list of ALL the records presented to them and not just their own.

    I have been trying to figure this out for 2 days now, and I have come to the conclusion that the records are being created correctly, but I must be using the filter incorrectly.

    Any help would be much appreciated. The plug in is just great for the community event I am helping to manage, but I need entrants to be able to access their own details and print them off.

    Thank you very much

    The page I need help with: [log in to see the link]

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

    (@xnau)

    OK, there were a couple of typos in that article due to a change in the code display plugin I’m using. these have been fixed, but just to be clear, your PHP snippet should be:

    <?php
    $current_user = wp_get_current_user();
    echo do_shortcode('[pdb_list filter="user_login=' . $current_user->user_login . '"]');
    ?>

    and that would be wrapped in whatever “use PHP in the content” shortcode you’re using.

    Now, if that’s not working, there are two things to check. First, check the shortcode string by simply echoing it out:

    <?php
    $current_user = wp_get_current_user();
    echo '[pdb_list filter="user_login=' . $current_user->user_login . '"]';
    ?>

    That should show the correct shortcode with the user’s login in the filter. That’s probably the issue, since it’s showing all the records, that indicates there is a problem with the filter: either the field name is wrong or for some reason the user_login value isn’t coming in.

    Thread Starter elitevacations

    (@elitevacations)

    Thank you very much for the response.
    I have used new snippet code you have sent me. The one I had from your tips page had a double set of square brackets.
    I have copied the [pdb_list filter="user_login=' . $current_user->user_login . '"]
    to the list page. That is the only thing on that list page.
    I have checked that the User Login field title actually reads user_login when a record is generated.
    All I get now is a blank screen on the list page.

    I have not been able to echo out the details in the code you sent as I don’t really know where to put that code to make it work.

    It’s driving me crazy!

    Plugin Author xnau webdesign

    (@xnau)

    OK, that code needs to go into your snippet, because it’s PHP. It won’t work directly on the page in that form.

    Thread Starter elitevacations

    (@elitevacations)

    Thank you for the help.
    I have pasted in the `<?php
    $current_user = wp_get_current_user();
    echo ‘[pdb_list filter=”user_login=’ . $current_user->user_login . ‘”]’;
    ?>` To mysnippet plug in.

    I have pasted the code into another snippet plug in, just in case that one is not working, and the result is the same.

    Then viewed the list page where I have the [pdb_list filter="user_login=' . $current_user->user_login . '"] filter.

    There is nothing shown at all, no errors it is as though something is not working, or there is something else required.

    If I remove current_user request from the filter, and replace it with an actual user like [pdb_list filter="user_login=Chris"] I get the correct listings associated to that user.

    Any ideas please?

    Plugin Author xnau webdesign

    (@xnau)

    Check your syntax in the snippet, there is probably an error. Make sure the quotes are “straight” sometimes copying code can give fancy quotes…also you don’t need the php tags in a snippet.

    Thread Starter elitevacations

    (@elitevacations)

    Got it – Finally:)
    Found a wobbly character, and updated the php snippet plug in.
    Happy Days!
    Thank you very much for the help

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Using PD with WP Users’ is closed to new replies.