Forum Replies Created

Viewing 15 replies - 1 through 15 (of 445 total)
  • Thread Starter justbishop

    (@justbishop)

    I figured it out! Looks like it was a cache issue 😀

    Thread Starter justbishop

    (@justbishop)

    Amazing, thank you!

    Thread Starter justbishop

    (@justbishop)

    Ughhhhh…so via process of elimination, I’ve discovered the issue arises when I activate the “pay to join” feature of the Pie Register plugin. Something about that is hijacking and altering things so that no post is created when the user registers. Works fine when registration is free and the user isn’t redirected to Paypal.

    Continuing on their support forum to see if they have a better action hook thing to replace user_register

    Can’t thank you enough for your help!

    Thread Starter justbishop

    (@justbishop)

    Thanks for the reply 🙂

    Actually it was debug mode that alerted me to the rogue code in a template file. That was literally the only line generated as I clicked around, so I don’t think there should be anything else lurking about.

    I fear it’s the Pie Register plugin that may be “hijacking” user_register, which will need to be resolved as I need to be able to charge a fee for registration, which is what I’m using Pie for in the first place. I did a bit of research and tried replacing user_register with one of the Pie actions that is apparently happening once it creates a new registered user, but that wasn’t generating the post I need, either.

    Next step is definitely the plugin deactivation/reactivation. Ughhhh.

    Thread Starter justbishop

    (@justbishop)

    Whew! Finally got the draft posts under control. Seems as if I’d stuck the code in a random template file at some point and forgotten to remove it. Issue located and resolved!

    The not-so-great part is that I still can’t get a post to generate when a user registers :'(

    Thread Starter justbishop

    (@justbishop)

    I thought that’s what I’d done, but maybe I’m not understanding? The site doesn’t have any traffic yet, as it’s still in testing/building stage. All of the draft posts are being created any time I delete the current ones, or navigate to a different screen in the admin area. I go back to the posts screen and the “Debug Data” posts have multiplied! I’ve also tried deleting cache and cookies in my browser, but they just keep coming!

    Anyway, here is the code in my plugin file, userpost.php. I looked into the db and found that the restaurant name value is being stored in usermeta –> pie_text_7 (I’m using the plugin Pie Register to add the collection field to the registration process):

    <?php
    
     /*
    
      Plugin Name: Auto-Create Post on User Registration
      Description: What it says on the tin
      Version: 1
      
    */
    
    add_action( 'user_register', 'restaurant_profile_create', 10, 1 );
    function restaurant_profile_create( $user_id )
    {
        // Get user info
      /* $user_meta = get_user_meta( $user_id, 'pie_text_7', true );
    
        // Create a new post
        $user_post = array(
            'post_title'   => $user_meta,
            'post_type'    => 'post', 
        );
        // Insert the post into the database
        $post_id = wp_insert_post( $user_post ); */
        
        
        $user_meta = get_user_meta( $user_id, 'pie_text_7', true );
    
        $user_post = array(
            'post_title'   => 'Debug Data',
            'post_type'    => 'post', 
        );
        $post_id = wp_insert_post( $user_post );
    
    }
    • This reply was modified 6 years, 6 months ago by justbishop.
    Thread Starter justbishop

    (@justbishop)

    Ok I commented out a portion of my plugin file code and inserted the above. Upon registering a test user, it produced 37 draft posts all titled “Debug Data,” most listing me as the author, but a few had a blank author.

    Progress? LOL

    ETA: Ahhhh!!!! Now it won’t stop generating these posts! Every time I refresh or delete them, more pop up in their place D:

    ETA2: It keeps happening, even after I’ve deactivated the plug with the code!

    ETA3: deleted the plugin containing the code from my server. Completely gone. Still, each time I delete the draft posts, WP is producing exactly 3 more draft posts, all titled “Debug Data”. I feel like I poured laundry soap in the dishwasher and n ow I can’t get things back under control!

    • This reply was modified 6 years, 6 months ago by justbishop.
    • This reply was modified 6 years, 6 months ago by justbishop.
    • This reply was modified 6 years, 6 months ago by justbishop.
    Thread Starter justbishop

    (@justbishop)

    Ok, nothing is working. Time to do this var_dump thing. I found the following code snippet elsewhere, but I have no idea where to put it. Functions.php?

    $sql = mysql_query("SELECT * FROM my_table WHERE key = 'restaurant_name'");
    $assoc = mysql_fetch_assoc($sql);
    
    // Dump variable containing the result of the MySQL query
    var_dump($assoc);
    Thread Starter justbishop

    (@justbishop)

    I don’t have a menu item called “PR Registration Form” nor one labeled “Form Editor Settings”. I finally found it by going to “Manage Forms” and editing the registration form in question. From there, this option is hidden in the area where you actually name the form and write any instructions (“Registration Form // Please fill in the form below to register” on the default form), in case anyone else comes along with the same question!

    Thread Starter justbishop

    (@justbishop)

    Thanks so much for explaining, but I’m not sure I’m getting it. This is what I thought needed changed, based on the advice given, but it’s still not working. No post created ><;;

    Posting the ENTIRE code in my plugin file. Maybe I’ve messed up something completely different?

    <?php
    
     /*
    
      Plugin Name: Auto-Create Post on User Registration
      Description: What it says on the tin
      Version: 1
      
    */
    
    add_action( 'user_register', 'restaurant_profile_create', 10, 1 );
    function restaurant_profile_create( $user_id )
    {
        // Get user info
       $user_meta = get_user_meta( $user_id, 'restaurant_name', true );
    
        // Create a new post
        $user_post = array(
            'post_title'   => $user_meta->restaurant_name,
            'post_type'    => 'post', 
        );
        // Insert the post into the database
        $post_id = wp_insert_post( $user_post );
    
    }
    
    ?>
    Thread Starter justbishop

    (@justbishop)

    If I’m understanding you and modifying correctly, you’re saying this possibly may be what I need?

    Thanks so much for all the help!

    add_action( 'user_register', 'restaurant_profile_create', 10, 1 );
    function restaurant_profile_create( $user_id )
    {
        // Get user info
        $user_meta = get_user_meta( $user_id, $key = 'restaurant_name', $single = true );
    
        // Create a new post
        $user_post = array(
            'post_title'   => $user_meta,
            'post_type'    => 'post', 
        );
        // Insert the post into the database
        $post_id = wp_insert_post( $user_post );
    
    }
    Thread Starter justbishop

    (@justbishop)

    Hm, yeah I probably should start a child theme. Thanks for reminding me that is a thing, lol!

    As for the post creation, I’ve checked my DB directly and confirmed it’s tossing the restaurant_name value into the usermeta table. Changed my code to the following and tried it both as a plugin and in functions.php. Still no luck. Am I not using get_user_meta correctly?

    Oh, and no I definitely do NOT want posts being published willy-nilly. Draft status is perfect!

    add_action( 'user_register', 'restaurant_profile_create', 10, 1 );
    function restaurant_profile_create( $user_id )
    {
        // Get user info
        $user_meta = get_user_meta( $user_id );
    
        // Create a new post
        $user_post = array(
            'post_title'   => $user_meta->restaurant_name,
            'post_type'    => 'post', 
        );
        // Insert the post into the database
        $post_id = wp_insert_post( $user_post );
    
    }
    • This reply was modified 6 years, 6 months ago by justbishop.
    Thread Starter justbishop

    (@justbishop)

    Will do, but is there no possible way to plugin-ize it? I don’t like making a bunch of changes to the theme that are going to be lost every time it updates!

    ETA: still doesn’t seem to work in the functions file ><;;

    • This reply was modified 6 years, 6 months ago by justbishop.
    Thread Starter justbishop

    (@justbishop)

    Well, I’m running into a real problem. I’m doing a test run of the registration fee (I have it set to $0.01), and when I hit the submit button on the reg form, it does redirect to the Paypal logon. I’m logging in using an email address and password I know are correct (I just checked by using them to log straight into Paypal in another tab), but the form keeps telling me “Check your email address and password and try again.”

    I have the payment gateway in the global settings using my Paypal account, and I’m trying to test the user registration with my husband’s Paypal account.

    Any ideas?

    Thread Starter justbishop

    (@justbishop)

    Oh my goodness, thank you so much!

Viewing 15 replies - 1 through 15 (of 445 total)