WordPress.org

Ready to get started?Download WordPress

Forums

Paid Memberships Pro
[resolved] File Upload help? (11 posts)

  1. rwilki
    Member
    Posted 5 months ago #

    I'm using the code from your register-helper plugin and it works for everything except I can't figure out the file upload field. I'm guessing that I have to create a directory or have it upload off-site, but I cannot find documentation anywhere.

    Here's the code I'm using:

    $resume = new PMProRH_Field("resume", "file", array("profile"=>true, "options"=>array()));
    pmprorh_add_registration_field("after_email", $resume);

    Thanks.

    https://wordpress.org/plugins/paid-memberships-pro/

  2. Great H-master
    Member
    Plugin Author

    Posted 5 months ago #

    Hello! Thank you for using Paid Memberships Pro. This behavior could be due to server folder permissions on your hosting. Try to "chmod 777" -R the permissions on your WordPress uploads directory (... wp-content/uploads/) and see if it works.

    Let us know what you find. Please change the permissions back to something more restrictive when you have completed testing, since "777" gives blanket access to any user. Thanks again.

  3. rwilki
    Member
    Posted 5 months ago #

    Nope. This didn't help but thanks for the idea. I'm kind of glad it wasn't a permission thing, because 777 is not a good idea.

    Anyway, this is what I'm getting:
    Fatal error: Using $this when not in object context in /home/xxxxx/xxxxxx/wp-content/plugins/pmpro-register-helper-master/classes/class.field.php on line 121

  4. messica
    Member
    Plugin Author

    Posted 5 months ago #

    Hey there,

    Could you please post a sample of your code, including the entire function declaration? Your code looks like it should work fine on first glance but maybe a better look would help.

    The Register Helper should actually be creating a folder in your wp-uploads folder with each of your users' uploads, so no, you don't need to do anything to configure that manually.

    Thanks,
    Jess

  5. rwilki
    Member
    Posted 5 months ago #

    thanks Jessica. what code do you want to see? Do you want to see the file "pmpro-register-helper.php" that I've edited?

    Here's the file:
    https://gist.github.com/73120400570181262134

  6. Great H-master
    Member
    Plugin Author

    Posted 5 months ago #

    Hello. Thank you for using Paid Memberships Pro. It appears you are editing the Register Helper plugin directly. The Register Helper is designed to work in conjunction with a separate plugin which contains your separate fields. Try the following...

    1)Re-download and install the Register Helper without the modifications
    2)Try downloading and installing the sample Register Helper Customization example plugin found here: https://github.com/strangerstudios/pmpro-register-helper

    Just to be clear there are 2 plugins involved here: The Register Helper and a separate plugin with your customizations like #2 above. Let us know if this works. Thanks again.

  7. rwilki
    Member
    Posted 5 months ago #

    Hi Great H-Master. thanks for your idea. Still getting the same error. I created the customization as a plugin and as an init in the functions file, but I'm getting the exact same error.

    Fatal error: Using $this when not in object context in /home/xxxxx/xxxxxx/wp-content/plugins/pmpro-register-helper-master/classes/class.field.php on line 121

    I feel like there's a conflict or it's a synatx issue...

  8. messica
    Member
    Plugin Author

    Posted 4 months ago #

    Sorry for the confusion, but are you saying you that you created a separate plugin, and added it into functions.php as well?

    All you need to do is add your code to one OR the other, not both. The lines are here: https://gist.github.com/rwilki/73120400570181262134#file-pmprohelp-L38-L57 should be wrapped in your own custom function, which should be hooked into init.. so either your active theme's functions.php file OR custom plugin (not both!) should contain something like this:

    function my_custom_fields() {
       // your code
    }
    add_action('init', 'my_custom_fields');

    Hope that helps!

  9. messica
    Member
    Plugin Author

    Posted 4 months ago #

    Additionally, it is not very good practice to reuse the same variable names for your fields ($text and $html in your case). It shouldn't break anything because you keep adding the new fields after declaring each one but it can definitely get confusing and messy. As Harsha mentioned above, you might want to try just copying and pasting the example code here http://www.paidmembershipspro.com/add-ons/plugins-on-github/pmpro-register-helper-add-checkout-and-profile-fields/ and edit it to suit your needs.

  10. rwilki
    Member
    Posted 4 months ago #

    Thanks Jessica. I appreciate your advice about not reusing the same variable. So, you're suggesting I group together all my $text fields into the same declaration? I will do that.

    BTW I have the register helper active untouched, and this is my customizations plugin. I'm not using the function init. Still getting the fatal error.

    function my_pmprorh_init()
    { 
    
    	$text = new PMProRH_Field("occupation", "text", array("size"=>40, "class"=>"occupation", "profile"=>true, "required"=>true));
    	pmprorh_add_registration_field("after_email", $text);
    
    	$text = new PMProRH_Field("employer", "text", array("size"=>40, "class"=>"employer", "profile"=>true, "required"=>true));
    	pmprorh_add_registration_field("after_email", $text);
    
    	$text = new PMProRH_Field("position", "text", array("size"=>40, "class"=>"position", "profile"=>true, "required"=>true));
    	pmprorh_add_registration_field("after_email", $text);
    
    	$history = new PMProRH_Field("history", "textarea", array("rows"=>10, "label"=>"In the space below..."));
    	pmprorh_add_registration_field("after_email", $history);
    
    	$html = new PMProRH_Field("uploadresume", "html", array("html"=>"<p>Or submit your resume below</p>"));
    	pmprorh_add_registration_field("after_email", $html);
    
    	$resume = new PMProRH_Field("resume", "file", array("profile"=>true, "options"=>array()));
    	pmprorh_add_registration_field("after_email", $resume);
    
    	$html = new PMProRH_Field("account", "html", array("html"=>"<p>Please enter a secure password for future access</p>"));
    	pmprorh_add_registration_field("after_password", $html);
    
    }
    add_action("init", "my_pmprorh_init");

    I removed the "php" and your slug at the top... for this post.

  11. rwilki
    Member
    Posted 4 months ago #

    Fixed thanks to Jason!!! So pumped. Such a great plugin!
    For anyone else who has this problem...
    https://github.com/strangerstudios/pmpro-register-helper/commit/92f927c09522ef648e84077ffcfdabe1c6157b58

    Thanks!

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.