Created
March 26, 2022 19:53
-
-
Save pstoute/6a22038f36184e14c2f2e8deee950642 to your computer and use it in GitHub Desktop.
Add meta user fields via Metabox.io so that Oxygen Builder can pull the field data.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add the fields via Metabox.io | |
**/ | |
function stoute_user_register_meta_boxes( $meta_boxes ) { | |
$prefix = 'social_'; | |
$meta_boxes[] = [ | |
'title' => esc_html__( 'Social Media', 'stoute_users' ), | |
'id' => 'social', | |
'type' => 'user', | |
'fields' => [ | |
[ | |
'type' => 'url', | |
'name' => esc_html__( 'Facebook', 'stoute_users' ), | |
'id' => $prefix . 'facebook', | |
], | |
[ | |
'type' => 'url', | |
'name' => esc_html__( 'Instagram', 'stoute_users' ), | |
'id' => $prefix . 'instagram', | |
], | |
[ | |
'type' => 'url', | |
'name' => esc_html__( 'LinkedIn', 'stoute_users' ), | |
'id' => $prefix . 'linkedin', | |
], | |
[ | |
'type' => 'url', | |
'name' => esc_html__( 'YouTube', 'stoute_users' ), | |
'id' => $prefix . 'youtube', | |
], | |
], | |
]; | |
return $meta_boxes; | |
} | |
add_filter( 'rwmb_meta_boxes', 'stoute_user_register_meta_boxes' ); | |
/** | |
* Add functions to have Oxygen pull the meta data | |
**/ | |
function get_author_facebook() { | |
$author_id = get_the_author_meta( 'ID' ); | |
$facebook_url = get_field('social_facebook', 'user_' . $author_id); | |
return $facebook_url; | |
} | |
function get_author_instagram() { | |
$author_id = get_the_author_meta( 'ID' ); | |
$instagram_url = get_field('social_instagram', 'user_' . $author_id); | |
return $instagram_url; | |
} | |
function get_author_linkedin() { | |
$author_id = get_the_author_meta( 'ID' ); | |
$linkedin_url = get_field('social_linkedin', 'user_' . $author_id); | |
return $linkedin_url; | |
} | |
function get_author_youtube() { | |
$author_id = get_the_author_meta( 'ID' ); | |
$youtube_url = get_field('social_youtube', 'user_' . $author_id); | |
return $youtube_url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment