• Resolved supernova42

    (@supernova42)


    Basically for simplicity my database might be reduced to the following fields
    [user_name][activity][leader_for_activity]

    The club has 2000 members with about 100 activities available. 75 members are appointed activity leaders and the activity they are responsible for is held in [leader_for_activity]. (I realise that there will be a lot of empty fields). There are actually 10 activity fields [activity_1] to [activity_10] but for simplicity I have just shown just 1 activity field [activity]. The activity leaders have been designated a different role to that of members.

    Basically, I would like the activity leaders to be able to see only the members who are enrolled in the activity that they are responsible for. Using the wp_get_current_user() I can get the user_name and use the shortcode

    echo do_shortcode(‘[pdb_list filter=”username=Drango” fields=”leader_for_activity”]’);

    to get the name of the activity. I now want to list the names of all members who have enrolled in that activity

    An ideal list would look like

    [Fred Jones] [Backgammon]
    …names of all members enrolled on Backgammon here


    Is there any way I can do this preferably without using Templates?

    I hope all that makes sense.

    Many Thanks

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

    (@xnau)

    It is possible to do something like this by using a different shortcode for each part of the page.

    Thread Starter supernova42

    (@supernova42)

    I am so close to finding a solution to this. I did as you said which was

    [insert_php]
    // Get the users login name
    $current_user = wp_get_current_user();
    $user_name=$current_user->user_login;

    /* Use the login name to find the activity. I used the responsive template but removed the pdb-field-title so that I could obtain just the activity name */

    $activity=do_shortcode(‘[pdb_list template=myresponsive filter=”username=’.$user_name.'” fields=”group_1″]’);

    /* I get the Activity Name but when slotted into my next shortcode it doesn’t work */

    echo do_shortcode(‘[pdb_list filter=”group_1=’.$activity.'”]’);

    I check the $activity string with strlen($activity) and it appears to be 715 characters long. I tried trimming the string but I cannot extract the name of the activity from the string. I checked the $activity string and it seems to contain html or CSS code which doesn’t show up and which I cannot get rid of.

    Please can you give me a few pointers.

    Many Thanks…

    Plugin Author xnau webdesign

    (@xnau)

    I don’t know how you are assigning a value to the $activity variable, so I can’t say what the problem is. You must assign that variable so that it has a string that will match one of the activities you have defined.

    Thread Starter supernova42

    (@supernova42)

    I’m assigning values to the $activity variable using a drop-down list in the Manage Database Fields.

    Part of the drop-down list is

    null_select::None,GAMES & PASTIMES ::optgroup,Backgammon::Backgammon,Bridge::Bridge,Bridge Duplicate 1::Bridge Duplicate 1,Bridge Duplicate 2::Bridge Duplicate 2,Bridge Duplicate 3::Bridge Duplicate 3,Cards For Fun::Cards For Fun,Cribbage::Cribbage,Cryptic Crackers::Cryptic Crackers,Mahjong for Beginners::Mahjong for Beginners,GENERAL INTEREST ::optgroup,Armchair Travel::Armchair etc etc

    Cheers

    Plugin Author xnau webdesign

    (@xnau)

    OK, well that doesn’t answer my question, because I don’t see how you’re assigning the $activity variable value. You just need to make sure that you’re getting the value you want into the $activity variable.

    Thread Starter supernova42

    (@supernova42)

    I have created a field called activity_1. The value for activity_1 is selected from that drop-down menu.

    I then use $activity=do_shortcode(‘[pdb_list template=myresponsive filter=”username=’.$user_name.'” fields=”activity_1″]’);

    This gives me the value of the variable stored in activity_1 but it seems to have lots of other hidden characters. If I do an echo strlen($activity); it gives me a value of 459.

    Cheers

    Plugin Author xnau webdesign

    (@xnau)

    OK, well, you’re dumping the output of the list shortcode into your variable, so that’s going to include a whole bunch of HTML. You just want the value of that single field.

    A more straightforward way to get that value is to get your record ID, then get the record data and use the field value from that, like this:

    <?php
    $record_id = Participants_Db::get_record_id_by_term('username', $user_name);
    $record = Participants_Db::get_participant( $record_id );
    $activity = $record['activity_1'];
    ?>

    now you have your $activity value and can show your filtered list.

    Thread Starter supernova42

    (@supernova42)

    Absolutely Fantastic – This little routine allows me to get the value of any variable within the database. It does exactly what I want.
    Many Thanks Once again for a superb plugin.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘A Filtering Problem’ is closed to new replies.