tribe_get_custom_field – Depreciated need alternate.

Home Forums Calendar Products Events Calendar PRO tribe_get_custom_field – Depreciated need alternate.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1625906
    Ken Charity
    Participant

    We are using the custom field feature to create a URL field, Just that one custom field..

    We were using is like so in our details.php file:
    $register_cf = tribe_get_custom_field( 'Register' );

    Then further down calling the variable like so:

    		<?php
    		// Event Registration
    		if ( ! empty( $register_cf ) ) : ?>
    			<div class="mec-event-more-info">
    			<i class="mec-sl-info"></i>
    				<dt> <?php esc_html_e( 'Registration:', 'the-events-calendar' ) ?> </dt>
    				<dd class="tribe-events-event-url"><a href="<?php echo $register_cf;?>" class="x-btn x-btn-large" style="text-shadow:none;color:#ffffff;margin:0.5em 0;">Register Online</a></dd>
    			</div>
    		<?php endif ?>

    Since the new function is now tribe_get_custom_fields() and brings an array over.

    How can I assign it to a variable? and for just the named field “Register”?

    #1625919
    Ken Charity
    Participant

    After some experimenting, I have updated my code to:

    //Custom fields
    $fields = tribe_get_custom_fields();
    $register_cf = $fields['Register'];

    This gets the $register_cf to have the content of the field, but is wrapping it automatically in <a> tag so that I cannot correctly format it and have the classes I want. So then do I have to strip the string of its tags so I can insert it the way I want?

    #1626978
    Jennifer
    Keymaster

    Hello,

    Thanks for reaching out!

    To get the plain URL without any markup, try using this instead:

    $field = get_post_meta( $event_id, '_ecp_custom_1' );

    -You may need to change the 1 in “_ecp_custom_1” to the correct ID for your field, which you can grab by viewing the source on the Additional Fields tab of the settings (see “name” in this screenshot) or by looking through all of the post meta:

    $field = get_post_meta( $event_id ); var_dump( $field );

    We are limited in the amount of support that we can provide for customizations, but if you get stuck or have any questions, please let me know – I’ll be happy to try to point you in the right direction!

    Thanks,

    Jennifer

    #1630085
    Ken Charity
    Participant

    That didn’t help. Much easier to just use strip_tags( $myvariable)

    My Solution:

    <?php
    
    //Custom fields
    $fields = tribe_get_custom_fields();
    $register_cf = $fields['Register'];
    
    // Event Registration
    if ( ! empty( $register_cf ) ) : ?>
    	<div class="mec-event-more-info">
    	<i class="mec-sl-info"></i>
    		<dt><?php esc_html_e( 'Registration:', 'the-events-calendar' ) ?></dt>
    		<dd class="tribe-events-event-url"><a href="<?php echo strip_tags( $register_cf );?>" class="x-btn x-btn-large">Register Online</a></dd>
    	</div>
    <?php endif ?>
    #1630105
    Jennifer
    Keymaster

    Hi Ken,

    I’m glad you found a better solution! If you run into any other issues, please don’t hesitate to reach out.

    #1644342
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘tribe_get_custom_field – Depreciated need alternate.’ is closed to new replies.