WordPress.org

Ready to get started?Download WordPress

Forums

[Participants Database] make all users WordPress users (10 posts)

  1. tmayombo
    Member
    Posted 2 years ago #

    Hi there

    I am using this great plugin called participant database but I want all my signed up users to become wordPress' users as well to give them more power and to log their activities on the site. So I decided to use a trigger in my database that would fire every time a [participants Database] user signs up. the problem is that the trigger doesn't fire and it stops the [participants Database] plugin from displaying thank you messages and to send emails. is there a better way to do this or is my trigger absolutely wrong. bellow is the code. Thanks for replying.:)

    delimiter $$
    CREATE TRIGGER user_insert
    AFTER insert ON participants_database FOR EACH ROW
    BEGIN

    INSERT into wp_users(ID,user_login,user_pass,user_nicename,user_email,user_registered,user_status,display_name)
    VALUES (id, CONCAT(new.first_name,' ',new.last_name),new.password,new.email,new.date_recorded,'Subscriber',CONCAT(new.first_name,' ',new.last_name)
    );

    END$$
    delimiter ;

  2. xnau
    Member
    Posted 2 years ago #

    tmayombo,

    Well, I have to commend you for finding a very creative solution to your need. I am not much of a MySQL programmer, so I would never have thought of this.

    I would say, even though I have no experience with this kind of function, that you are getting an error that you are not seeing. You should try turning on the WP_DEBUG flag on your wp-config.php file to see if you can catch the error. The error is stopping any further processing, so this is why you're not getting the thank you page.

    Once you see the error, that should help you correct any problems you might have with your code.

    --Roland

  3. tmayombo
    Member
    Posted 2 years ago #

    Hi xnau

    Thanks for your answer.I have unable the debug in config.php and here is what i get before running the trigger.

    ----------------------------------------------------------------------
    Notice: wp_enqueue_script was called incorrectly. Scripts and styles
    should not be registered or enqueued until the wp_enqueue_scripts,
    admin_enqueue_scripts, or init hooks. Please see Debugging in WordPress
    for more information. (This message was added in version 3.3.) in
    /usr/www/users/nalibrxvyr/wp-includes/functions.php on line 3587 Notice:
    get_usermeta is deprecated since version 3.0! Use get_user_meta() instead.
    in /usr/www/users/nalibrxvyr/wp-includes/functions.php on line 3467 Notice:
    get_usermeta is deprecated since version 3.0! Use get_user_meta() instead.
    in /usr/www/users/nalibrxvyr/wp-includes/functions.php on line 3467
    -----------------------------------------------------------------------

    Bellow is what I get after inserting a new user

    -----------------------------------------------------------------------
    WordPress database error: [Column count doesn't match value count at row 1]
    INSERT INTO wp_participants_database SET date_updated = NOW(), first_name = 'ted',
    last_name = 'eda', email = 'ted@digivox.co.za', password = 'qwerty', i_am_signing_up_as = 'a:1:{i:0;s:6:
    \"Parent\";}',
    member_of =
    'Community', mailing_list = 'Yes',
    reading_club_ = 'Yes', contact_permission = NULL,
    http://wwwnalibaliorg/sign_up/ = NULL, private_id = 'XJBKT',
    club_name = NULL, where = NULL, when = '1333929600', average_number_of_members =
    '0-5', contact_person = NULL, contact_email = NULL, are_you_a_member? = 'Yes',
    language_i_speak_at_home = 'English', tell_us_more = NULL, additional_hard_copies =
    'Yes', hall_of_fame = 'Yes', address = NULL, city = NULL, state = NULL, country =
    'South Africa', zip = NULL, phone = NULL, photo = NULL, see_your_profile = NULL, donations = NULL,
    volunteered = NULL, resources = NULL

    Warning: Cannot modify header information - headers already sent
    by (output started at /usr/www/users/nalibrxvyr/wp-includes/functions.php:3587)
    in /usr/www/users/nalibrxvyr/wp-includes/pluggable.php on line 866 Notice: get_usermeta
    is deprecated since version 3.0! Use get_user_meta() instead. in /usr/www/users/nalibrxvyr/wp-includes/functions.php
    on line 3467

    ----------------------------------------------------------------------

    The only problem is that I don't seem to locate this get_usermeta in /usr/www/users/nalibrxvyr/wp-includes/functions.php
    on line 3467. So I am just wondering what should I actually be doing?

    Thanks again xnau

  4. tmayombo
    Member
    Posted 2 years ago #

    Hi Xnau

    could please explain me where and how the plugin inserts data into the participats_databases table. I think I will be able to produce a cleaner way of making all users wordpress users just by duplicating how the plugin inserts this data into the participants_database table and by changing the term participants_database to wp_users.

  5. xnau
    Member
    Posted 2 years ago #

    tmayombo,

    Well, doing the kind of thing you're doing is how I learned how to customize WordPress and plugins.

    The basic issue you're running into here is the difference in structure between a WP user and a record in the plugin. They are quite different, so I would suggest your start by examining the two databases and figure out how one translates to the other. You won't be able to just change which database the record gets written to...it will be more complicated than that. There is a WP function that adds a user, I think that would be a far easier way to go than to try to change how the plugin writes to the database.

    good luck! --Roland

  6. tetontrekker
    Member
    Posted 2 years ago #

    @tmayombo,

    I was having the same header error when setting up some nested plugins on custom pages with minimal WordPress code. I fixed it by moving my custom pages directly under the WordPress folder, I think I had some redundancy and this was my easy fix. It's probably not the correct way to fix it but hopefully this will help you find a solution to your error.

    ~Julie

  7. tmayombo
    Member
    Posted 2 years ago #

    @tetontrekker

    Hi tetontrekker and thanks for the advice. However, I have a small question for you. What do you mean by custum pages? Do you mean a page with its own template? On my site I use only wordpress pages and I haven't yet started to custumize templates. However I have added the plugin shortcodes in some of my current pages.

    Thanks in advance.

  8. tmayombo
    Member
    Posted 2 years ago #

    @xnau

    Hi xnau and thanks for the tips. I have downloded the plugin on my desktop and I have started to scrutnize the code. There is a lot of code and I must admit I don't understand it all but I know PHP classes quite well. The file that attracted my attention is the PDb_Int.class.php there I get the sense that datbases are initited in that file and I understand what is going on. However I am still strugling to find the code I need. Let me make myself more easy to understand. In the PDb_Int.class.php I can describ what is hapnning as such: create database->put in the default values. what I am loking for is the code saying: after new data are entered and checked for validation-> put this content in the database. when I find that code I can find a way to capture the data entered by the user and run the create/update users wordpress funtion as you suggested.

    Regards

  9. xnau
    Member
    Posted 2 years ago #

    tmayombo,

    You'll find that function in participants-database.php named "process_form" in the "Participants_Db" class. That function processes all form submissions that write to the database.

    Be warned, however, that this class has gotten way out of hand in terms of size, so I am planning to split it up into several classes in the future.

  10. tetontrekker
    Member
    Posted 2 years ago #

    @tmayombo

    Sorry for the delay, last week was crazy and I have a piccolo solo in our upcoming concert so practice is a priority right now.

    I have done both, I made my own blank template without a header or footer, and my own custom made page with minimal code to call information to a page outside the WordPress folder with include. The setup is like this:

    My Website
    ->WordPress
    ->->wp-subfolder
    ->->wp-subfolder
    ->->wp-subfolder
    ->->custompage.php

    The custom pages have minimum code to run WordPress. I found how to do that in instructions for making templates. The trick is the shortcode, two things to remember. You have to use PHP to run the shortcode and each plugin uses various scripts that have to be called. Participants Database, fortunately, runs with only the basics.

    You can see some of my custom pages in action here:
    http://www.jhcband.org/
    The news ticker is more of a hack, it uses a plugin called "Scheduled Announcements Widget" then since I can't write PHP in it and it will not read shortcode I had to create a separate page for the birthdays and use iframes to call it. (Otherwise this plugin was perfect for my needs) To get the birthdays I used a separate field for the birth month and birth day in the PDb. For the birth month field I used a dropdown with all the months and one "-" for people who do not want to be listed on the birthday list. Here is the birthday code:

    <?php
    $today = date("F");
     ?>
    <div class="jhcb_birthday">
    <?php
    // Use shortcode in a PHP file (outside the post editor).
     echo do_shortcode('[pdb_list list_limit=100 filter="status=Active&birth_month='.$today . '" fields="first_name, last_name, instrument"]');
     ?>
    </div>

    From the main page on my site you can click Members & Contact us to see other examples of calling custom pages with includes.

    The blank template I created is used for reports and are private, search templates using the search box on top of this page for how to start a template. The rest of the code is about the same.

    Have a great day!
    Julie

Topic Closed

This topic has been closed to new replies.

About this Topic