Forum Replies Created

Viewing 15 replies - 136 through 150 (of 191 total)
  • Thread Starter supernova42

    (@supernova42)

    I have refined this a little and it can be used to pass all WordPress user records to the Participants Database. However, the one thing I’m still stuck on is how do I create the actual Participants Database Record.
    Many Thanks

    `[insert_php]
    echo ‘<b>Creating New PD Records for the following WordPress Users</b><br /> ‘;
    for ($id=1; $id<=1000; $id++) {
    $user = get_user_by( ‘id’, $id );
    $wp_id = $user->id;
    $wp_username = $user->user_login;
    $wp_email = $user->user_email;
    $wp_first_name = $user->user_firstname;
    $wp_last_name = $user->user_lastname;
    if (!empty($wp_username)) {
    $user_id = Participants_Db::get_record_id_by_term(‘username’, $wp_username);
    if (empty($user_id)) {
    echo $wp_id.’ : ‘.$wp_username.’ : ‘.$wp_email.’ : ‘.$wp_first_name.’ ‘.$wp_last_name.'<br />’;
    /*Create New PD Record Here*/
    }
    }
    }
    [/insert_php]

    supernova42

    (@supernova42)

    The only unique fields are Record_ID and UserName and regardless of how many staff you have with the same name, they will have different UserNames. You can use the above functions to obtain the UserName of the person logged in. Once you have that UserName you can obtain the Record_ID and First_Name, Last_Name etc.

    It’s just a question of modifying the functions to suite your purpose…

    supernova42

    (@supernova42)

    I had a similar problem. The difficulty I had is that the Participants Database Record ID will be totally different to the WordPress ID so I used UserName instead because these two fields will be the same.

    I found that by using php I could achieve so much more within Participants Database and therefore I used the Plugin ‘Insert php’ by Will Bontrager. Remember when you enter the php code you must be in TEXT mode and not VISUAL mode. I initially made that mistake.

    [insert_php]
    $current_user = wp_get_current_user();
    $users_name=$current_user->user_login;
    /*This will give the UserName of the current user*/

    $user_firstname=$current_user->user_firstname
    $user_lastname=$current_user->user_lastname
    /*This will give the first and last names of the current user*/

    echo do_shortcode(‘[pdb_list template=responsive filter=”username=’.$users_name.'” fields=”record_id,first_name,last_name,etc”]’);
    [/insert_php]

    I did actually modify the responsive filter to give me a slightly different layout, but it’s not important at this stage.

    You might have to play around with this to get exactly what you want, but try it out and see how you go.

    Another useful method you could try is

    [insert_php]
    $current_user = wp_get_current_user();
    $user_name=$current_user->user_login;
    $user_id = Participants_Db::get_record_id_by_term(‘username’, $user_name);
    $record = Participants_Db::get_participant( $user_id );
    echo do_shortcode(‘[pdb_record record_id=’.$user_id.’]’);
    [/insert_php]

    supernova42

    (@supernova42)

    A very easy way of doing this is by using a plugin like ‘Nav Menu Roles’ by Kathy Darling. You can actually restrict which menu a user can access dependent on their role. It isn’t perfect but you might like to try it out in the interim.

    supernova42

    (@supernova42)

    Hi Hans

    I have just tried this out and got it working.
    Firstly make sure you have set the field to a date field.
    When you enter a date using the format 31-12-1943 it is translated to the format December 31, 1943 within the database. Therefore you should use the filter of
    [pdb_list filter=”DOB<31-12-1943″].

    It works for me. Of course you can also use
    [pdb_list filter=”date_of_birth<December 31, 1943″]

    I have found the Participants Database to be a fantastic plugin but it has very specific formatting options that you need to follow. Just practice and perserverance really.

    Cheers

    Thread Starter supernova42

    (@supernova42)

    It appears that the ID value in the Participants Database is an arbitrary value created by the system and cannot be amended. This limitation makes the importing of WordPress users data very restrictive and would ask why you have this limitation (with regard to ID value) in place.

    I’m using the Shortcode [pdb_record record_id=ID] but if the WordPress User id and Participants Database id’s do not match I have to resort to additional functions in order to obtain the required record. I’ve managed to do this using other functions, but it could be so much easier if the imported WordPress ID was used to create a new Participants Database ID so that the two fields matched.

    In the Import Function you already have a drop-down with 3 options
    1. Create a New Record with the submission
    2. Update matching record with new date
    3. Don’t import the record

    What about a 4th option which would allow the WordPress ID values to be imported so that the ID values in the WordPress database match the ID values in the Participants Database.

    If at some time in the future that you create a function or routine to align the Participants Database with the WordPress backend database, then surely matched id values will be an essential requirement. At the moment I have to export my WordPress users data and import it into the Participants Database which is a bit tedious. At the moment I do this on a weekly basis as I cannot see any other way of doing it. It would be so good if this was an automatic function.

    Another possible solution would be if when using the [pdb_record] shortcode, I could use ‘username’ in addition to ‘record_id’ to locate my record. Both id and username are fixed ‘read-only’ fields which cannot be modified by the administrator.

    Many Thanks

    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.

    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

    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

    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…

    Thread Starter supernova42

    (@supernova42)

    Absolutely fantastic does exactly what I want and more. It’s just a question of being able to find what you want in the documentation.
    Many Thanks

    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

    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…

    supernova42

    (@supernova42)

    Is it possible some other plugin is causing the problem. I’ve had similar problems and so I disable the lot and start adding them back one by one. It might not be the actual problem but at least it eliminates the other plugins as a problem.

    Thread Starter supernova42

    (@supernova42)

    Hi Roland
    For me I think the Participants Database is one of the best plugins available – I find it so useful and so inspiring that I’ve now started to learn php. I’ve managed to get the routine working and have shown it below in case other users might be interested. After making a selection from the drop-down menu the user has to press SUBMIT – Not perfect but the best I’ve managed so far. Ideally, I would like to lose the SUBMIT button and just have the list displaying from a selection in the Drop Down menu.
    Many Thanks

    [insert_php]
    $activities=array(“Anthropology”,”Armchair Travel”,”Art History”,”Autobiography”,”Backgammon”,”Ballroom for Beginners”);

    //Fill drop down menu with values from array
    echo “<form>”;
    echo ‘<select name=”activity”>’;
    for($i=0; $i<count($activities); $i++)
    {
    echo ‘<option value=”‘ . ($i+1) . ‘” >’ . $activities[$i];
    }
    echo ‘</select>’;
    echo “<form>”;

    echo “<input type=’submit’>”;
    $activity_id=$_REQUEST[‘activity’];

    //Make selection from array
    $activity=$activities[$activity_id-1];

    //Display the selected List
    echo “<br/> <br/>”;
    echo “The Following Members are in the [” . $activity . “] Group”;

    echo do_shortcode(‘[pdb_list filter=”group_1=’.$activity.’|group_2=’.$activity.’|group_3=’.$activity.’|group_4=’.$activity.’|group_5=’.$activity.’|group_6=’.$activity.’|group_7=’.$activity.’|group_8=’.$activity.’|group_9=’.$activity.’|group_10=’.$activity.'” fields=”role,title,initials,first_name,last_name,zip,membership”]’);
    [/insert_php]

Viewing 15 replies - 136 through 150 (of 191 total)