0

I am using a hook from Paid Membership pro to add ACF fields on a registration form.

function insert_acf() {
    echo "<p><div id='content-creator'>Test</div></p>
    <p><?php the_field('organisation_name'); ?></p>";
 };

add_action('pmpro_checkout_before_submit_button','insert_acf');

Problem 1: The test div works but it is not displaying the ACF field

Problem 2: How do I associate this ACF field to the newly created subscriber

TIA

closed as off-topic by Michael, Mark Kaplun, Pat J, Jack Johansson, Howdy_McGee Jan 15 '18 at 16:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    This is probably something you would want to take up with Paid Membership Pro's support. – Cedon Jan 4 '18 at 15:34
  • Thanks but there is only support on their $297 per year. subscripton I wouldn’t mind spending that if I knew it was going to work, but currently had patchy results with other membership plugins. So I need to see it would work first – Nick Wild Jan 4 '18 at 15:37
  • Why has somebody downvoted? – Nick Wild Jan 4 '18 at 17:02
  • 2
    @NickWild Why has somebody downvoted? Possibly to emphasize that WPSE is not intended as a site to provide support for third-party plugins. – Pat J Jan 4 '18 at 18:32
  • 1
    @admcfajn good idea but not specifically for PMP just userforms – Nick Wild Jan 4 '18 at 19:25
2

There is an error in your echo. You are trying to echo a php opening tag. change your function to:

function insert_acf() {
    echo "<p><div id='content-creator'>Test</div></p><p>" . get_field('organisation_name') . "</p>";
};

This will solve your first problem.

  • Thanks but it does not show up – Nick Wild Jan 4 '18 at 15:41
2

Try this:

function insert_acf() {
    $rtfield = "<p><div id='content-creator'>Test</div></p>
    <p>". get_field('organisation_name')."</p>";
    return $rtfield;
 };

add_action('pmpro_checkout_before_submit_button','insert_acf');

Now in your dashboard you need to add that field to your user form by going to custom fields, add new field group (or if you already created this field) simply set display if post is user form.

You'll now need to go to a user and add something to the field and save the user changes.

I would also add a conditional to your code in case some of your users don't have the field with data it it yet:

function insert_acf() {
  if (get_field('organisation_name')) {
    $rtfield = "<p><div id='content-creator'>Test</div></p>
    <p>". get_field('organisation_name')."</p>";
    return $rtfield;
  }else{
    return;
  }
}
  • Hi, thanks good advice, but this does not even show the test in the div. – Nick Wild Jan 4 '18 at 20:57
  • which is "this"? if you used the 2nd version then it won't because the conditional may not be met. – rudtek Jan 4 '18 at 20:59
  • I only tried the first one – Nick Wild Jan 4 '18 at 21:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.