I have added this multi-check field in WordPress user profile page
$tprofile_user_fight_info->add_field(
array(
'id' => '_user-fighting-style',
'name' => __( 'Your fighting styles', 'tprofile' ),
'type' => 'multicheck',
'options' => array(
'fs_one' => __('MMA', 'tprofile' ),
'fs_two' => __( 'Kikboxing', 'tprofile' ),
'fs_three' => __( 'Boxing', 'tprofile' ),
'fs_four' => __( 'Judo', 'tprofile' ),
'fs_five' => __( 'Taekwondo', 'tprofile'),
'fs_six' => __( 'Karate', 'tprofile' ),
'fs_seven' => __( 'Brazilian Jiu-jitsu', 'tprofile' ),
'fs_eight' => __( 'Wrestling', 'tprofile' ),
'fs_nine' => __( 'Capoeira', 'tprofile' ),
'fs_ten' => __( 'Muay Thai', 'tprofile' ),
'fs_eleven' => __('Karate Kyokushinkai', 'tprofile' ),
'fs_twelve' => __('Kudo Daido Juku', 'tprofile' ),
)
)
);
And I am trying retrieve the checked values in wp_list_table. But in the table there showing the keys instead of values. Please help me, how can I get the values in the table? Below is the code where I trying to retrieve the values:
$tprofile_users = get_users( array( 'role__in' => array( 'subscriber' ) ) );
foreach( $tprofile_users as $tprofile_user ){
global $current_user;
$user_id = $current_user->ID;
$tprofile_user_cmeta = get_the_author_meta( $user_id );
$data_array[] = [
'fighting_style' => esc_html( $tprofile_user->$tprofile_user_cmeta['_user-fighting-style'][0] ),
}
return $data_array;
Result is showing like this:
a:3:{i:0;s:6:"fs_one";i:1;s:7:"fs_four";i:2;s:8:"fs_eight";}
Related
How do I hide/display a link in BuddyPress toolbar if the user has a particular role?
function your_bp_admin_bar_add() {
global $wp_admin_bar, $bp;
if ( !bp_use_wp_admin_bar() || defined( 'DOING_AJAX' ) )
return;
$user_domain = bp_loggedin_user_domain();
if (current_user_can('lp_teacher')) {
$wp_admin_bar->add_menu( array(
'parent' => $bp->my_account_menu_id,
'id' => 'my-create-course',
'title' => __( 'Create Course', 'your-plugin-domain' ),
'href' => trailingslashit( 'https://mywebsite.com/wp-admin/post-new.php?post_type=lp_course&tab=course_settings' ),
'meta' => array( 'class' => 'menupop' )
) );
}
$wp_admin_bar->add_menu( array(
'parent' => $bp->my_account_menu_id,
'id' => 'my-account-dogs',
'title' => __( 'Become an Instructor', 'your-plugin-domain' ),
'href' => trailingslashit( 'https://mywebsite.com/become-a-teacher-2/' ),
'meta' => array( 'class' => 'menupop' )
) );
}
add_action( 'bp_setup_admin_bar', 'your_bp_admin_bar_add', 300 );
I don't understand why it only displays Become an Instructor even when the logged-in user is an instructor. It is supposed to display Create Course.
I don't understand why it only displays Become an Instructor even when the logged-in user is an instructor.
Are you sure that the role / capability for instructors is lp_teacher?
If you want to only show Create Course to instructors, then try adding an else:
if (current_user_can('lp_teacher')) {
$wp_admin_bar->add_menu( array(
'parent' => $bp->my_account_menu_id,
'id' => 'my-create-course',
'title' => __( 'Create Course', 'your-plugin-domain' ),
'href' => trailingslashit( 'https://mywebsite.com/wp-admin/post-new.php?post_type=lp_course&tab=course_settings' ),
'meta' => array( 'class' => 'menupop' )
) );
} else {
$wp_admin_bar->add_menu( array(
'parent' => $bp->my_account_menu_id,
'id' => 'my-account-dogs',
'title' => __( 'Become an Instructor', 'your-plugin-domain' ),
'href' => trailingslashit( 'https://mywebsite.com/become-a-teacher-2/' ),
'meta' => array( 'class' => 'menupop' )
) );
}
I want to add product meta in my Online Cosmetics Store like the above screenshot.
This meta data is exists in an opencart website shop4shops.in. I want to add the same meta data in my Woocommerce store.
Your help, will be appreciated.
i will give you small demo for how to add meta for product.
in function.php file add following code.
add_filter( 'rwmb_meta_boxes', 'pharmacy_meta_boxes' );
function pharmacy_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array(
'title' => __( 'Extra Product Info', 'pharmacy' ),
'fields' => array(
array(
'id' => 'unit',
'name' => __( 'Unit', 'pharmacy' ),
'type' => 'text',
'datalist' => array(
'options' => array(
__( 'Box', 'pharmacy' ),
__( 'Blister pack', 'pharmacy' ),
__( 'Packet', 'pharmacy' ),
__( 'Bottle', 'pharmacy' ),
),
),
),
array(
'id' => 'dosage_form',
'name' => __( 'Dosage form', 'pharmacy' ),
'type' => 'text',
'datalist' => array(
'options' => array(
__( 'Capsule', 'pharmacy' ),
__( 'Tablet', 'pharmacy' ),
__( 'Liquid', 'pharmacy' ),
__( 'Ointment', 'pharmacy' ),
),
),
),
);
return $meta_boxes;
}
And to save that meta write following in your function
add_action( 'woocommerce_product_meta_end', 'pharmacy_extra_info' );
function pharmacy_extra_info()
{
if ( $meta = rwmb_meta( 'unit' ) )
{
echo '<strong>' . __( 'Unit:', 'pharmacy' ) . "</strong> $meta<br>";
}
if ( $meta = rwmb_meta( 'dosage_form' ) )
{
echo '<strong>' . __( 'Dosage form:', 'pharmacy' ) . "</strong> $meta<br>";
}
}
I hope this following code help you to add meta in your product and you can add more product meta like this way.
and you can also follow
this link
Thank You.
I saw "Background image not saving in WordPress Customizer"
But didn't get any help.
My code is
function sorcey_customize_register($wp_customize){
$wp_customize->add_section('sorcey_footer', array(
'title' => __('Footer', 'sorcey'),
'description' => '',
'priority' => 120,
));
/* =============================
Footer logo
===============================*/
$wp_customize->add_setting('sorcey_footer_logo', array(
'default' => '',
'capability' => 'edit_theme_options',
'type' => 'text',
));
$wp_customize->add_control( new WP_Customize_Cropped_Image_Control(
$wp_customize, 'sorcey_footer_logo_ctrl', array(
'label' => __( 'Footer Logo', 'sorcey' ),
'section' => 'sorcey_footer',
'settings' => 'sorcey_footer_logo',
'height' => '40px',
'width' => '160px',
'button_labels' => array(
'select' => __( 'Select logo' ),
'change' => __( 'Change logo' ),
'remove' => __( 'Remove' ),
'default' => __( 'Default' ),
'placeholder' => __( 'No logo selected' ),
'frame_title' => __( 'Select logo' ),
'frame_button' => __( 'Choose logo' ),
),
)
));
}
I Tryed for output by
echo get_theme_mod( 'sorcey_footer_logo' );
And
echo wp_get_attachment_url( get_theme_mod( 'sorcey_footer_logo' ) );
And
var_dump(get_theme_mod( 'sorcey_footer_logo' ));
But showing 'boolean false'
add_filter( 'rwmb_meta_boxes', 'your_prefix_meta_boxes' );
function your_prefix_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array(
'title' => __( 'Custom theme 2 Metabox ', 'textdomain' ),
'post_types' => array('page'),
'fields' => array(
array(
'id' => 'htitle',
'name' => __( 'Home Page Title ', 'textdomain' ),
'type' => 'text',
),
array(
'id' => 'titlecss',
'name' => __( 'Title CSS', 'textdomain' ),
'type' => 'checkbox',
'desc' => __( 'CSS For "WELCOME TO"', 'your-prefix' ),
),
array(
'id' => 'titlecss2',
'name' => __( 'Title CSS2', 'textdomain' ),
'type' => 'checkbox',
'desc' => __( 'CSS For "Company name"', 'your-prefix' ),
),
),
);
return $meta_boxes;
}
help to get checkbox value i got value of text box like this
<?php echo rwmb_meta( 'htitle' ); ?>
but i m not able to fetch value of checkbox please help
<?php echo rwmb_meta( 'titlecss' ); ?
i got it by using id of checkbox
I want to display a custom taxonomy page.
$microblogging_taxonomy_slug="theme";
$microblogging_taxonomy_singular="theme";
$microblogging_taxonomy_plural="themes"
$labels = array(
'name' => $microblogging_taxonomy_plural,
'singular_name' => $microblogging_taxonomy_singular,
'search_items' => sprintf( __( 'Search %s',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_plural) ),
'all_items' => sprintf( __( 'All %s',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_plural) ),
'parent_item' => sprintf( __( 'Parent %s',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_singular) ),
'parent_item_colon' => sprintf( __( 'Parent %s :',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_singular) ),
'edit_item' => sprintf( __( 'Edit %s',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_singular) ),
'update_item' => sprintf( __( 'Update %s',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_singular) ),
'add_new_item' => sprintf( __( 'Add new %s',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_singular) ),
'new_item_name' => sprintf( __( 'New %s',LANGUAGE_MICROBLOGGING ), strtolower($microblogging_taxonomy_singular) ),
'menu_name' => $microblogging_taxonomy_plural,
);
$args = array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
'rewrite' => array( 'slug' => $microblogging_taxonomy_slug ),
);
register_taxonomy( MB_CUSTOM_TAX_1_NAME, array( "post" ), $args );
now I want to create a template for this page "mysite.dev/theme/". Is it possible?
I create this taxonomy with a plugin and so I would use a filter like
add_filter( 'taxonomy_template', 'mb_get_custom_taxonomy_template' );
For example I use a function, attached to the 'archive_template' filter hook, to replace tax original theme template
function mb_get_custom_post_type_template_archive($archive_template) {
global $taxonomy,$term,$wp_query;
global $mb_css_js_version;
if (is_tax() && $taxonomy == MB_CUSTOM_TAX_1_NAME) {
$archive_template = MB_TEMPLATE_CUSTOM_TAX_1_DIR . "index.php";
}
else if (is_post_type_archive(MB_POST_TYPE)) {
$archive_template = MB_TEMPLATE_ARCHIVE_DIR . "post_type_archive/index.php";
}
return $archive_template;
}
With this function I can view my plugin template
ex. mysite.dev/theme/theme-1 mysite.dev/theme/theme-2