• Resolved o.heinrich

    (@oheinrich)


    Hi,

    I added a custom field in Mailpoet.
    Now I want to include this custom field in a newsletter.
    How can I read the value of the custom field via php?

    I searched for hours but without any success.
    I only found this function, which gives me the custom fields, but not the values:

    WJ_Field::get_all(array('order_by' => 'name ASC'));

    Result:

    Array
    (
        [0] => WJ_Field Object
            (
                [table:WJ_Field:private] => wp_wysija_custom_field
                [user_table:WJ_Field:private] => wp_wysija_user
                [id] => 1
                [name] => PLZ
                [type] => input
                [required] =>
                [settings] => Array
                    (
                        [required] => 0
                        [validate] =>
                    )
    
            )
    
    )

    Does anybody has an idea? Any suggestion would be great!

    Thanks in advance,
    Oliver

    https://wordpress.org/plugins/wysija-newsletters/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Have you read this: https://support.mailpoet.com/knowledgebase/hook-to-add-your-own-shortcode/ ? Also, we don’t provide support for custom code.

    Thread Starter o.heinrich

    (@oheinrich)

    Yes, I read this post before, it’s the base or my code.
    I would not say that this is customization in a common sense. IMHO this is a lack of documentation.

    I would expect from a professional plugin like Mailpoet at least a basic documentation how to use it.

    Therefore it would be great if you can document how to read the value of a custom field via php. For you as the development team giving an answer to this should be a no-brainer.

    I see it the same way. We pay money for a “professional” newsletter plugin but when it comes to just a bit of customization there is no help at all. Your documentation is simply lousy.

    Thread Starter o.heinrich

    (@oheinrich)

    I solved the problem with a workaround:
    I read out the data directly from the MySQL-database without using the Mailpoet-API:

    // Make variable global to get access to DB
    global $wpdb; 
    
    // Get ZIP of subscribers:
    // cf_2 is the name of the custom field -> replace by the name of your field
    foreach( $wpdb->get_results("SELECT cf_2 FROM wp_wysija_user WHERE user_id ='".$user_id."'") as $key => $row) {
    	$zip = $row->cf_2;
    }

    I hope this helps you and other users of Mailpoet.

    @mailpoet: Shame on you!

    @o.heinrich: Thank you! In case you find/found a better solution, providing it would be greatly appreciated. 😉

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Get values of custom fields’ is closed to new replies.