• Hi there I’m using custom attributes to show a link. A custom field for this link is set by a plugin I use and the purpose is that it allows a user to link directly to the source page of the event. I’ve got it in the formats in single event and the code that displays the custom field is:

    {has_att_the_custom_field1}
    <strong>More Event Info:</strong>
    <br><a href="#_ATT{the_custom_field1}" target="_blank">#_ATT{the_custom_field1}</a>
    <br><br>{/has_att_the_custom_field1}

    But this adds a field to the event registration form also, where users submit from the front end, which we don’t want as it is not relevant for front end users, only imported events, and so it looks untidy. How can I can prevent this, isolate it in css to hide it or prevent it from being added to the form, please? Thanks a lot

Viewing 8 replies - 1 through 8 (of 8 total)
  • Create a custom field instead of a custom attribute. Custom fields can only be set in the backend (or with your plugin).

    https://wp-events-plugin.com/documentation/event-attributes/

    Thread Starter Kir 2012

    (@kir-2012)

    Hi there thanks for replying ??
    I saw this but doesn’t it outline that the display of the custom field should be carried out with the att etc (code above) – and it’s the use of that in my single event format in settings that’s causing it to automatically appear on the form, isn’t that right? Is there a better way to add it to an event page if it’s present in the post?
    Thanks

    No, using att etc (code above) will not cause it to automatically appear on the form if you go to settings in the General tab and you set “Enable event attributes” to No and set “Enable event custom fields” to Yes.

    Thread Starter Kir 2012

    (@kir-2012)

    Hi, thanks but I can’t do that as I have other unrelated attributes that need displaying. So I’ve got both custom fields and attributes on at the mo. Is there code I should be using other than this to display the custom field value from the plugin in the single event section of formats tab, with that in mind?

    {has_att_the_custom_field1}
    <strong>More Event Info:</strong>
    <br><a href="#_ATT{the_custom_field1}" target="_blank">#_ATT{the_custom_field1}</a>
    <br><br>{/has_att_the_custom_field1}

    Or if entering that code in format for single event isn’t causing it to appear on add event form, might you know what is causing the field to be added, so that I can address it?

    To clarify further, whereas I have added the attributes I wish to appear on the form, and then display on an event post, this one custom field comes when I import an event from elsewhere, I don’t add it in admin. It’s there already. I wish to display it on the event page, which I have done, using the above code. But if I add this code into the single event in the format tab, it immediately adds it to the form. When I remove it from the the single event format, it removes it from the form.
    Thanks ??

    • This reply was modified 1 year, 3 months ago by Kir 2012.
    • This reply was modified 1 year, 3 months ago by Kir 2012.
    Thread Starter Kir 2012

    (@kir-2012)

    In your link above it says:

    “Now we need to define our attributes by giving them names and possible values. Attributes are defined by either adding them to your attributes box in the same settings page where you activated attributes above, or entering them directly into your formats on the settings page. Events Manager will detect that there is a new attribute and generate the right form fields on the event or location registration page.” Can I do something to prevent that from happening for this particular item? Prevent that function from running for just that one custom field name?

    Either that or if you could help me understand what I should be entering into the single event format window on the formats tab, to bring in this custom field without it adding to the form that would be brilliant ??

    • This reply was modified 1 year, 3 months ago by Kir 2012.

    Don’t create any custom attribute or custom field in the events manager settings (in the General tab). Instead create a meta key and meta value with your plugin. Let’s say the meta key is called “the_custom_field1”. You will then be able to add the following?in the single event section of formats tab

    <a href="#_ATT{the_custom_field1}" target="_blank">#_ATT{the_custom_field1}</a>
    Thread Starter Kir 2012

    (@kir-2012)

    Hi there, thanks for your reply, but there is nothing in the attributes section of the settings tab, I haven’t used that. The ‘attributes’ option is on, (nothing appears as a field in the event registration form otherwise), but the other fields like ‘website’ and ‘price’, these are only added in the format tab for single event, using similar code to your example above, but conditional as in the code paste. I tried your code as described also, but the field still remains on the add event form, is there anything else I could try? Perhaps amending the code in attributes public template in my child theme to make an exception in the code for that custom field name, where it adds detected attributes to the form? Is there a good way to do that?
    Thanks

    Thread Starter Kir 2012

    (@kir-2012)

    Hi there, thanks for your input to help me I really appreciate it.

    I solved this now for anyone else who could benefit, I put the code below in the single layout from my theme (in child theme of course) to show the link when the custom field is present :

    	<center><?php
      if ( get_post_meta( $post->ID, "my_custom_field_name_with_url_values", true ) ){
        echo '<div class="pros"><p><strong><h2>More Event Info:</h2>  </strong><a href="' .
        get_post_meta( $post->ID, "my_custom_field_name_with_url_values", true ) .
        '" target="_blank">' .
        get_post_meta( $post->ID, "my_custom_field_name_with_url_values", true ) .
        '</a></p></div>';
      }
    ?></center>
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Hide custom field / attribute from event reg form’ is closed to new replies.