Support Forum » User Profile

Forum Replies Created

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • Denise FieldDenise Field
    Participant

    For reference if anyone else wants to use that plugin the entire function to display the custom post is

    
    add_action( 'woocommerce_after_main_content', 'add_alt_description', 10 );
    
    function add_alt_description(){
    	$term_id = get_queried_object_id();
    	$value = rwmb_meta( 'alt_page_id', ['object_type' => 'term'], $term_id );
    	echo '<div class="container"><div class="alt-category"><div class="alt-category__page"><div class="alt-category__content"> ' ;
    	
    	echo do_shortcode("[insert page='$value' ]");
    	echo '</div></div></div></div>'; 
    
    }
     
     

    *** The insert page shortcode does strip all the divs from the page you may have set up for styling so I just added them back in with this function ***

    This was just perfect for large content to display in the product category pages, so much better than the tiny box woocommerce gives you!

    Denise FieldDenise Field
    Participant

    Thank you, its now working!

    in reply to: Select Template for Post Type missing #39089
    Denise FieldDenise Field
    Participant

    thank you that worked perfectly!

    Denise FieldDenise Field
    Participant

    I solved it myself thank you, here is how I did it , for anyone else wishing to do this that has some level of skill but not a developer.

    1. Created the Custom Field Types using the Metabox interface. Set them up exactly as I want, without the default value.
    2. Clicked Get PHP Code and copied that code, minus the <?php tag into my functions.php
    3. Added my PHP query to get the user details
    `global $current_user;
    get_currentuserinfo();
    $user_name = $current_user->display_name;
    $user_email = $current_user->user_email;
    $user_first = $current_user->user_firstname;
    $user_last = $current_user->user_lastname; `

    4. added the 'std' => $user_name, etc etc to each field to show the correct variable
    5. output the shortcode of the form <?php echo do_shortcode("[mb_frontend_form id='request-membership-status' ]") ?>
    Job Done!!!
    Here is the complete function I created so if anyone else wants to follow it they can see how it has to be set up as a working function for the MB Frontend Submission form.

    add_filter( 'rwmb_meta_boxes', 'request_membership_status' );
    
    function request_membership_status( $meta_boxes ) {
        $prefix = '';
    
        // your code to get the current user name here
    	global $current_user;
    	get_currentuserinfo();
        $user_name = $current_user->display_name;
    	$user_email = $current_user->user_email;
    	$user_first = $current_user->user_firstname;
    	$user_last = $current_user->user_lastname;
    
        $meta_boxes[] = [
            'title'      => __( 'Request Membership Status', 'pinkequine-com' ),
            'id'         => 'request-membership-status',
            'post_types' => ['membership-request'],
            'fields'     => [
                [
                    'name'          => __( 'First Name', 'pinkequine-com' ),
                    'id'            => $prefix . 'user_first',
                    'type'          => 'text',
                    'admin_columns' => 'replace title',
                    'std'			=> $user_first,
                ],
                [
                    'name'          => __( 'Last Name', 'pinkequine-com' ),
                    'id'            => $prefix . 'user_last',
                    'type'          => 'text',
                    'admin_columns' => 'after user_first',
    				'std'			=> $user_last,
                ],
                [
                    'name'          => __( 'Username', 'pinkequine-com' ),
                    'id'            => $prefix . 'user_name',
                    'type'          => 'text',
                    'admin_columns' => 'after user_last',
    				'std'			=> $user_name,
                ],
                [
                    'name'          => __( 'Email', 'pinkequine-com' ),
                    'id'            => $prefix . 'user_email',
                    'type'          => 'text',
                    'admin_columns' => 'after user_name',
    				'std'			=> $user_email,
                ],
                [
                    'name'              => __( 'Membership', 'pinkequine-com' ),
                    'id'                => $prefix . 'checkbox_membership',
                    'type'              => 'checkbox',
                    'label_description' => __( 'Please add user Member to my profile', 'pinkequine-com' ),
                    'required'          => true,
                    'admin_columns'     => 'after user_email',
                ],
            ],
            'validation' => [
                'rules'    => [
                    $prefix . 'checkbox_membership' => [
                        'required' => true,
                    ],
                ],
                'messages' => [
                    $prefix . 'checkbox_membership' => [
                        'required' => 'Please check the box to confirm your request',
                    ],
                ],
            ],
        ];
    
        return $meta_boxes;
    }
    Denise FieldDenise Field
    Participant

    Morning, can I just clarify, is there a way, using MB Builder and Frontend Form Submission, to set the std to a variable?

    Denise FieldDenise Field
    Participant

    EDIT: I corrected a typo on the last 2 variables.

    Here is how I am calling the form and that shows up exactly as expected
    echo do_shortcode ("[mb_frontend_form id='request-membership-status' ]")

    And here is one of the form fields to be populated with the variables
    Screenshot

    Denise FieldDenise Field
    Participant

    I think I must be doing something wrong? The code isnt populating the fields on the form, do I need to add something to the shortcode?

    Here is the function I created

    add_filter( 'rwmb_meta_boxes', function ( $meta_boxes ) {
        // your code to get the current user name here
    	global $current_user;
    	get_currentuserinfo();
        $user_name = $current_user->display_name;
    	$user_email = $current_user->user_email;
    	$user_first = $current_user->user_firstname;
    	$user_last = $current_user->user_lastname;
    
        $meta_boxes[] = [
            
            'fields'     => [
                [
                    'name' => 'username',
                    'id'   => 'user_name',
                    'type' => 'text',
                    'std' => $user_name
                ],
    			[
                    'name' => 'email',
                    'id'   => 'user_email',
                    'type' => 'text',
                    'std' => $user_email
                ],
    			[
                    'name' => 'firstname',
                    'id'   => 'user_firstname',
                    'type' => 'text',
                    'std' => $user_firstname
                ],
    			[
                    'name' => 'lastname',
                    'id'   => 'user_lastname',
                    'type' => 'text',
                    'std' => $user_lastname
                ],
            ],
        ];
    
        return $meta_boxes;
    } );

    Can you help?

    Denise FieldDenise Field
    Participant

    Thanks I did see that on the docs, but thought it was more of a general setting and I wondered about conflicts - e.g all user name fields as user_name that it would cause an issue in the post_meta table.

    However, if I am understanding what you are saying is that I could have several fields e.g.user_name1, user_name2 etc and then declare them each in here with the same variable name in this case $user_name.

    Thank you for this, I've literally read so much php/sass/jquery etc my eyes are going funny! Sometimes you can't see the wood, for the trees!

    in reply to: User Profile update user role overwrites additional roles #38929
    Denise FieldDenise Field
    Participant

    Just one more thing, if your Devs do include it, all they need to do is to ensure that the record is not completely overwritten

    Other plugins have added user roles this is how the usermeta looks:

    a:3:{s:8:"customer";b:1;s:14:"yith_affiliate";b:1;s:9:"um_member";b:1;}

    So, something like if the role to be added does not exist, then add it, not overwrite the original, especially as woocommerce adds customer as the primary user and relegates all others.

    Hope that helps with the dev.

    in reply to: User Profile update user role overwrites additional roles #38928
    Denise FieldDenise Field
    Participant

    I see, I will probably have to make it a manual request for now then via email because I have am using the plugins USER ROLE EDITOR, YITH AFFILIATES and WOOCOMMERCE all of these add user roles to the main one.

    Thank you for your consideration of this in future updates though.

    Denise FieldDenise Field
    Participant

    Thank you that sorted it! It wasnt working at first because I'd changed the fieldname to something random after I had put the metabox entry on the configurator post, but I went into the postmeta and changed it to the renamed one and it works a dream!!!! Thank you

    Denise FieldDenise Field
    Participant

    Thank you that worked!

    in reply to: Meta box Group with tags showing up twice in output #38417
    Denise FieldDenise Field
    Participant

    Ok I solved it myself, I was using the wrong code snippet

    I used this and it worked

    <?php $values = rwmb_meta( 'my_field_id' ); ?>
    <ul>
        <?php foreach ( $values as $value ) : ?>
            <li><?= $value ?></li>
        <?php endforeach ?>
    </ul>
    in reply to: Meta box Group with tags showing up twice in output #38416
    Denise FieldDenise Field
    Participant
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly.
    }
    
    global $post;
    
    $short_description = apply_filters( 'woocommerce_short_description', $post->post_excerpt );
    
        if ( ! $short_description )
            return;
    
        // Bullet Points
        $bullet_points = '<ul class="product__short-description--bullets">' .  rwmb_the_value( "product_bullet_point" ) . '</ul>';
        
        // The custom text
        $custom_text = '<ul class="product__short-description--bullets--red">
        <li>Please see our <a href="https://www.pinkequine.com/buyers-guide/">Buyers Guide</a> for current delivery times on Bespoke Products</li>
        </ul>';
          ?>
        
        <div class="product__short-description">
            <?php echo $short_description . $bullet_points . $custom_text ; // WPCS: XSS ok. ?>
        </div>
    in reply to: Meta box Group with tags showing up twice in output #38415
    Denise FieldDenise Field
    Participant

    Sorry am having trouble getting the images to show up
    Here is the Browser Output

    Here is the Source Code

Viewing 15 posts - 1 through 15 (of 15 total)