Viewing 10 replies - 16 through 25 (of 25 total)
  • Thread Starter ruen06

    (@ruen06)

    This happens to both newly registered users and existing users on my site. It just doesn’t create the folder in wp-content/uploads anymore

    • This reply was modified 1 year, 11 months ago by ruen06.

    @ruen06

    Have you set “Disable Profile Photo Upload”
    in UM Settings -> Appearance -> Profile ?

    Thread Starter ruen06

    (@ruen06)

    Yes all the time.

    Also remember it worked perfectly previously.

    @ruen06

    You can replace all of the current um-vcard.php file
    with this new code version 1.1.0:

    <?php
    /*
    Plugin Name: Ultimate Member - VCard
    Plugin URI: https://www.ultimatemember.com
    Description: Adds a predefined field to generate VCard for users to download from their profiles.
    Version: 1.1.0
    Author: Ultimate Member Ltd.
    Author URI: https://www.ultimatemember.com
    Text Domain: um-vcard
    */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	die( 'You are not allowed to call this page directly.' );
    }
    
    define( 'UM_VCARD_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    define( 'UM_VCARD_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
    
    // Composer dependencies.
    if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
    	require __DIR__ . '/vendor/autoload.php';
    }
    
    use JeroenDesloovere\VCard\Formatter\Formatter;
    use JeroenDesloovere\VCard\Formatter\VcfFormatter;
    use JeroenDesloovere\VCard\Parser\Parser;
    use JeroenDesloovere\VCard\Parser\VcfParser;
    use JeroenDesloovere\VCard\Property\Address;
    use JeroenDesloovere\VCard\Property\Anniversary;
    use JeroenDesloovere\VCard\Property\Birthdate;
    use JeroenDesloovere\VCard\Property\Email;
    use JeroenDesloovere\VCard\Property\Gender;
    use JeroenDesloovere\VCard\Property\Logo;
    use JeroenDesloovere\VCard\Property\Name;
    use JeroenDesloovere\VCard\Property\Nickname;
    use JeroenDesloovere\VCard\Property\Note;
    use JeroenDesloovere\VCard\Property\Parameter\Kind;
    use JeroenDesloovere\VCard\Property\Parameter\Revision;
    use JeroenDesloovere\VCard\Property\Parameter\Type;
    use JeroenDesloovere\VCard\Property\Parameter\Version;
    use JeroenDesloovere\VCard\Property\Photo;
    use JeroenDesloovere\VCard\Property\Telephone;
    use JeroenDesloovere\VCard\Property\Title;
    use JeroenDesloovere\VCard\Property\Role;
    use JeroenDesloovere\VCard\Property\Url;
    use JeroenDesloovere\VCard\VCard;
    
    /**
     * Generate VCard on profile update
     *
     * @param integer $user_id The current user's ID.
     */
    function um_vcard_generate( $user_id ) {
    
    	um_fetch_user( $user_id );
    	$lastname   = um_user( 'last_name' );
    	$firstname  = um_user( 'first_name' );
    	$additional = um_user( 'display_name' );
    	$prefix     = um_user( 'prefix' );
    	$suffix     = um_user( 'suffix' );
    
    	$user_dir = UM()->uploader()->get_upload_user_base_dir( $user_id ) . DIRECTORY_SEPARATOR;
    	if( !file_exists( $user_dir )) {
    		wp_mkdir_p( $user_dir );
    	}
    
    	$vcard = new VCard( null, Version::version3() );
    	$vcard->add( new Name( $lastname, $firstname ) );
    	$vcard->add( new Title( um_user( 'title' ) ) );
    	$vcard->add( new Role( um_user( 'role' ) ) );
    	$vcard->add( new Telephone( um_user( 'mobile_number' ) ) );
    	if ( file_exists( $user_dir . um_profile( 'profile_photo' ) ) && is_file( $user_dir . um_profile( 'profile_photo' ) ) ) {
    		//$sizes    = UM()->options()->get( 'photo_thumb_sizes' );
    		//$min_size = min( $sizes );
    		//$avatar   = str_replace( 'profile_photo', 'profile_photo-' . $min_size . 'x' . $min_size, $user_dir . um_profile( 'profile_photo' ) );
    		
    		$avatar   = $user_dir . um_profile( 'profile_photo' );
    		$data     = file_get_contents( $avatar );
    		// we should split this large string into smaller 72-symbols strings, to correspond the standard.
    
    		$vcard->add( new Photo( $data ) );
    		$vcard->add( new Logo( $data ) );
    
    	}
    
    	add_action( 'um_vcard_before_save', $vcard, $user_id );
    
    	$formatter = new Formatter( new VcfFormatter(), 'vcard' );
    	$formatter->addVCard( $vcard );
    	$formatter->save( $user_dir );
    
    	update_user_meta( $user_id, 'vcard', 'vcard.vcf' );
    
    }
    add_action( 'um_after_user_updated', 'um_vcard_generate' );
    add_action( 'um_registration_complete', 'um_vcard_generate' );
    
    /**
     * Add Vcard predefined field.
     *
     * @param array $fields predefined fields array.
     */
    function um_vcard_add_field( $fields ) {
    	$fields['vcard'] = array(
            'title'    => __( 'VCard', 'ultimate-member' ),
            'metakey'  => 'vcard',
            'type'     => 'file',
            'label'    => __( 'VCard', 'ultimate-member' ),
            'required' => 0,
            'public'   => 1,
            'editable' => false,
            'icon'     => 'um-icon-card',
            'color'    => '#6441A4',
    	);
    
    	return $fields;
    }
    add_filter( 'um_predefined_fields_hook', 'um_vcard_add_field', 10, 1 );
    
    // Don't display the field in Edit View.
    add_filter( 'um_vcard_form_edit_field', '__return_empty_string' );

    @ruen06

    There is a new beta test version of the VCard Plugin available with more User fields.

    user_url
    phone_number
    user_email
    description
    gender
    birth_date
    nickname
    full_name

    Thread Starter ruen06

    (@ruen06)

    Thanks much! The code works.

    Thread Starter ruen06

    (@ruen06)

    I hope your team can maintain the updates for vcard and provide more featues such as generate the beautiful biocard before downloading the vcard etc.

    @ruen06

    Do you want a copy of the new version of the VCard plugin?

    Thread Starter ruen06

    (@ruen06)

    Is the beta version fully tested?

    @ruen06

    The new vCard source was submitted for release 8 days ago.
    My addition of the folder creation must be added too.
    I have the final version and can post a copy here for you to test.

    https://github.com/ultimatemember/Extended/pull/14/commits/97b1bf535d95a68f2710d4d313b2c26f6aa43e74

    https://github.com/ultimatemember/Extended/issues/15

Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘Vcard extension doesn’t work anymore’ is closed to new replies.