Custom fields for Social Marketing

Is it possible to extend custom field support to SM?

Thanks

EDIT: is there a hook that would allow this...

add_filter( '??????', 'add_sm_custom_fields' );
function add_sm_custom_fields($args) {
     $args['supports'] = array( 'thumbnail', 'custom-fields');
     return $args;
}
  • wecreateyou
    • The Crimson Coder

    Also I was reading another post that mentioned the name for this plugin wasn't ideal. I kind of agree although it's certainly not a big deal to me. anyway here are some ideas I had based on what I think the plugin is all about.

    Social Marketing Rewards
    Social Marketing Incentives
    Social Incentives
    Marketing Incentives
    Social Rewards
    Ad Rewards

  • wecreateyou
    • The Crimson Coder

    Thanks David, I'd really love to see this ability with all custom post type plugins. It's a big timesaver when it comes to integrating front-end forms with CPT's

    also... what are the field names for this plugin? If not I need to know them.

    wdsm_url
    wdsm_button_text
    wdsm_type
    wdsm_download_url
    wdsm_coupon_code
    wdsm_share_text

  • Vladislav
    • Dead Eye Dev

    Hello,

    I agree, custom fields can be very useful for extending and gluing plugins together. In the latest plugin release (v1.1.1, just released), the supported array is filtered, which means that you can use the piece of code from your opening post to allow custom fields and featured image. Of course, you'll want to substitute "????" with the filter name, which is "wdsm-social_marketing-post_type-supports" (it is called from lib/class_wdsm_social_marketing.php, around line 143 - class "Wdsm_SocialMarketing", method "register_post_type").

    As for field names, the plugin custom post type stores its metadata in a serialized array, with meta key "wdsm".

  • univiz
    • Flash Drive

    @VeBailovity

    You mentioned above about including a 'Featured Image'. Can you please explain how to do this?

    As explained in https://premium.wpmudev.org/forums/topic/posts-any-image-for-the-thumbnail?replies=7#post-180169 the plugin is either:

    a) picking up a random image (never the featured image or product image)

    b) as a temporary workaround I added a generic image to the og:image meta in the header as you suggested *but* when adding links directly on the Facebook page, that is now picking up the generic image and does not give an option, as it did previously, to choose a thumbnail.

    Many thanks.

  • Vladislav
    • Dead Eye Dev

    Hi,

    The code to enable featured image support for Social Marketing ads is pretty much as posted by wecreateyou in the opening post. However, this code will only *allow* featured images, not actually output them for you.

    As for Facebook sharing, if you don't specify an image using and OpenGraph header, Facebook will pick some images from your page as it sees fit. You can have more then one og:image, which will enable your users to flip through your multiple images when sharing a page.

  • wecreateyou
    • The Crimson Coder

    Hi again,

    I placed this code in my functions:

    add_filter( 'wdsm-social_marketing-post_type-supports', 'add_sm_custom_fields' );
    function add_sm_custom_fields($args) {
         $args['supports'] = array( 'title', 'editor', 'custom-fields');
         return $args;
    }

    I'm getting this error message at the top of the admin page.

    Warning: Illegal offset type in /home/xxxx/public_html/wp-includes/post.php on line 1268

    Also editing the plugin adding custom-fields did work. I just have the code wrong. Thanks for any help.

  • Vladislav
    • Dead Eye Dev

    Hello,

    The arguments passed to the filter are in fact a regular array of supported features, not a hash. So, the exact code you may want to use to add, say, custom fields would be something like this:

    <?php
    add_filter( 'wdsm-social_marketing-post_type-supports', 'add_sm_custom_fields' );
    
    function add_sm_custom_fields($args) {
    	return array('title', 'editor', 'custom-fields');
    }

    This will work, but it's not really flexible. An easier and more flexible approach would be:

    <?php
    add_filter( 'wdsm-social_marketing-post_type-supports', 'add_sm_custom_fields' );
    
    function add_sm_custom_fields($args) {
    	$args[] = 'custom-fields';
    	return $args;
    }

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.