Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 18 replies - 1 through 18 (of 18 total)

  • leanneoleary
    Participant

    @leanneoleary

    Can anyone help please?


    leanneoleary
    Participant

    @leanneoleary

    OK will do. In the meantime I would be happy to have a message on the homepage saying, β€œYour account is now activated. Please login here”. Do you know how this would be implemented?


    leanneoleary
    Participant

    @leanneoleary

    Hi, I had seen that article but then couldn’t find the plugin within wordpress so was unsure of using it. I will give it a go though if that’s the only solution available, thanks.

    UPDATE
    ——-
    Just tried uploading it to wordpress but get errors and looking at the comments on the page of the plugin looks like it hasn’t worked since 2012/13. πŸ™


    leanneoleary
    Participant

    @leanneoleary

    Yes its only a problem if they don’t have the following info, “Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! ” ? $ % ^ & ).’”

    I have managed to add this sentence to the form with JQuery so I haven’t had to amend any existing code.

    Thanks for you help.


    leanneoleary
    Participant

    @leanneoleary

    There isn’t a problem that needs tracking down. I simply need to add a password hint to the register page. How would you suggest I do this without editing the files?


    leanneoleary
    Participant

    @leanneoleary

    I am using Cinematix (http://themeforest.net/item/cinematix-buddypress-theme/4959387) and haven’t customised it in any way.

    I have found the default HINT for wordpress is the following:

    <?php _e(‘Hint: The password should be at least seven characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! ” ? $ % ^ & ).’); ?>

    I assume this is what is being used? If so I can just add this password hint but what file do I need to edit?

    Many thanks for your help.


    leanneoleary
    Participant

    @leanneoleary

    Thats great, thankyou πŸ™‚


    leanneoleary
    Participant

    @leanneoleary

    Anyone?


    leanneoleary
    Participant

    @leanneoleary

    Seriously? All I was missing was the ‘/’; ?

    Thanks so much for your help.


    leanneoleary
    Participant

    @leanneoleary

    That’s great, thanks!

    Unfortunately the theme Im using has two sets of filters; one set of filters is listed across the top with ‘All Members’, ‘Friends’, ‘Favorites’, ‘mentions’. This is where I want to add ‘Personal’. Then there is another filter in the form of a drop down which has ‘new members’, ‘posts’, ‘comments’ etc which is where your code has placed the ‘personal’ filter option.

    This is the code I currently have in activity/index.php:
    <li id="activity-me"> <a id="just-me" href="<?php echo bp_loggedin_user_domain() . bp_get_activity_slug() ?>">Personal</a>

    Is it easy to adjust the code above so that it uses the code you have supplied to add the correct ajax filter? Ive tried playing around with your code but had no joy getting it to work.

    Many thanks for your help.


    leanneoleary
    Participant

    @leanneoleary

    Found some code that will ensure only files uploaded that thatuser are displayed inthe Media Library.

    add_action(‘pre_get_posts’,’ml_restrict_media_library’);
    function ml_restrict_media_library( $wp_query_obj ) {
    global $current_user, $pagenow;
    if( !is_a( $current_user, ‘WP_User’) )
    return;
    if( ‘admin-ajax.php’ != $pagenow || $_REQUEST[‘action’] != ‘query-attachments’ )
    return;
    if( !current_user_can(‘manage_media_library’) )
    $wp_query_obj->set(‘author’, $current_user->ID );
    return;
    }


    leanneoleary
    Participant

    @leanneoleary

    That worked a treat, thank you! πŸ™‚


    leanneoleary
    Participant

    @leanneoleary

    Thank you, I will look into those.


    leanneoleary
    Participant

    @leanneoleary

    Thank you. This looks like a theme I would need to purchase which I don’t want to do as I have already purchased a theme.

    Can anyone help direct me to where the code for the activiy page is? I suppose thats the best starting point!

    thanks


    leanneoleary
    Participant

    @leanneoleary

    OK, I discovered I needed to remove the code from my class and add it to the main functions.php page to work.


    leanneoleary
    Participant

    @leanneoleary

    Where exactly should I be adding this code?


    leanneoleary
    Participant

    @leanneoleary

    I have checked and Site Tracking is enabled. I have implemented the code as you have said but nothing happens. The form is submitted as usual but nothing appears in the activity stream. I don’t even know if the function is being activated as I have tried using print_r($post_types); within the function but still nothing.


    leanneoleary
    Participant

    @leanneoleary

    Thanks for your help with this but I am still not sure what I need to do. The function I posted was just an example that I had found from an earlier forum, I do not need to add videos and pictures to the activity stream.

    I need to add details of a custom post type every time a custom form is submitted from the frontend by a user. The custom post type is “Files”. Below is a class for the form and it is within the CMB (custom meta boxes) plugin folder. Can you advise on how to implement the code to record these forms posts in the activity stream?

    class uploadForm {
    
        // Set prefix
        public $prefix = '_cmb_'; 
    
        /**
         * Construct the class.
         */
        public function __construct() {
            add_filter( 'cmb_meta_boxes', array( $this, 'cmb_metaboxes' ) );
            add_shortcode( 'cmb-form', array( $this, 'do_frontend_form' ) );
            add_action( 'init', array( $this, 'initialize_cmb_meta_boxes' ), 9 );
           /* add_action( 'cmb_save_post_fields', array( $this, 'save_fields' ), 10, 4 );*/
            add_action( 'save_post', array( $this, 'save_fields' ), 10, 4 );
           /*add_filter( 'bp_blogs_record_comment_post_types', 'add_activity' );   IS THIS CORRECT?  */ 
        }
    
        /**
         * Define the metabox and field configurations.
         */
        public function cmb_metaboxes( array $meta_boxes ) {
    
            /**
             * Metabox for the "Memorials" front-end submission form
             */
            $meta_boxes['upload_files_metabox'] = array(
                'id'         => 'files',
                'title'      => __( 'Upload files', 'cmb' ),
                'pages'      => array( 'Files' ), // Post type
                'context'    => 'normal',
                'priority'   => 'high',
                'show_names' => true, // Show field names on the left
                'fields'     => array(
                    array(
                        'name'       => __( 'File description', 'cmb' ),
                        'desc'       => __( 'File title or description', 'cmb' ),
                        'id'         => $this->prefix . 'title',
                        'type'       => 'text',
                    ),
                    array(
                        'name'     => __( 'Project stage', 'cmb' ),
                        'desc'     => __( 'select stage (optional)', 'cmb' ),
                        'id'       => $this->prefix . 'category',
                        'type'     => 'taxonomy_select',
                        'taxonomy' => 'stages', // Taxonomy Slug
                    ),
                    array(
                        'name' => __( 'Link to website', 'cmb' ),
                        'desc' => __( 'Add url to website (optional)', 'cmb' ),
                        'id'   => $this->prefix . 'url',
                        'type' => 'text_url',
                        'protocols' => array('http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet'), // Array of allowed protocols
                        // 'repeatable' => true,
                    ),
                   array(
                        'name' => __( 'Upload image', 'cmb' ),
                        'desc' => __( 'Upload an image or enter a URL.', 'cmb' ),
                        'id'   => $this->prefix . 'image',
                        'type' => 'file',
                    ),
    
                  array(
                      'name'         => __( 'Upload files', 'cmb' ),
                      'desc'         => __( 'Upload or add multiple images/attachments.', 'cmb' ),
                      'id'           => $this->prefix . 'file_list',
                      'type'         => 'file_list',
                  ),
                  array(
                    'name' => __( 'oEmbed', 'cmb' ),
                    'desc' => __( 'Enter a youtube, twitter, or instagram URL. Supports services listed at <a href="https://codex.wordpress.org/Embeds">https://codex.wordpress.org/Embeds</a>.', 'cmb' ),
                    'id'   => $this->prefix . 'embed',
                    'type' => 'oembed',
                 ), 
                ),
            );
    
            return $meta_boxes;
        }
    
        /**
         * Shortcode to display a CMB form for a post ID.
         */
        public function do_frontend_form() {
    
            // Default metabox ID
            $metabox_id = 'upload_files_metabox';
    
            // Get all metaboxes
            $meta_boxes = apply_filters( 'cmb_meta_boxes', array() );
    
            // If the metabox specified doesn't exist, yell about it.
            if ( ! isset( $meta_boxes[ $metabox_id ] ) ) {
                return __( "A metabox with the specified 'metabox_id' doesn't exist.", 'cmb' );
            }
    
            // This is the WordPress post ID where the data should be stored/displayed.
            $post_id = 0;
    
            if ( $new_id = $this->intercept_post_id() ) {
                $post_id = $new_id;
                echo 'Thank You for your submission.';
            } 
    
            // Shortcodes need to return their data, not echo it.
            $echo = false;
    
            // Get our form
            $form = cmb_metabox_form( $meta_boxes[ $metabox_id ], $post_id, $echo );
    
            return $form;
        }
    
        /**
         * Get data before saving to CMB.
         */
        public function intercept_post_id() {
    
            // Check for $_POST data
            if ( empty( $_POST ) ) {
                return false;
            } 
             
            
    
            // Check nonce
            if ( ! ( isset( $_POST['submit-cmb'], $_POST['wp_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wp_meta_box_nonce'], cmb_Meta_Box::nonce() ) ) ) {
                return;
            }
            
            // Setup and sanitize data
            if ( isset( $_POST[ $this->prefix . 'title' ] ) ) {
                           
              
                //add post data to database    
                $this->new_submission = wp_insert_post( array(
                    'post_title'            => sanitize_text_field( $_POST[ $this->prefix . 'title' ] ),
                    'post_author'           => get_current_user_id(),
                    'post_status'           => 'publish', // Set to draft so we can review first
                    'post_type'             => 'file',
                ), true );
    
                // If no errors, save the data into a new post draft
                if ( ! is_wp_error( $this->new_submission ) ) {
                    
                    return $this->new_submission;
                    
                   
                } 
    
            }
    
            return false;
        }
    
        /**
         * Grant temporary permissions to subscribers.
         */
        public function grant_publish_caps( $caps, $cap, $args ) {
    
            if ( 'edit_post'  == $args[0] ) {
                $caps[$cap[0]] = true;
            }
    
            return $caps;
        }
        
       
        
    
        /**
         * Save custom fields and uploaded files 
         */
        public function save_fields( $post_id, $post  ) {
    
                if($_POST['_cmb_category'] != ''){
                    add_post_meta( $post_id, '_cmb_category', $_POST['_cmb_category'], true );
                }
                if($_POST['_cmb_url'] != ''){
                    add_post_meta( $post_id, '_cmb_url', $_POST['_cmb_url]'], true );
                }
                if($_POST['_cmb_image'] != ''){
                    add_post_meta( $post_id, '_cmb_image', $_POST['_cmb_image'], true );
                }
                if($_POST['_cmb_image_id'] != ''){
                    add_post_meta( $post_id, '_cmb_image_id', $_POST['_cmb_image_id'], true );
                }
                if($_POST['_cmb_file_list'] != ''){
                    add_post_meta( $post_id, '_cmb_file_list', $_POST['_cmb__file_list'], true );
                }
                if($_POST['_cmb_embed'] != ''){
                    add_post_meta( $post_id, '_cmb_embed', $_POST['_cmb_embed'], true );
                }
           
    
        }
    
        /**
         * Initialize CMB.
         */
        public function initialize_cmb_meta_boxes() {
    
            if ( ! class_exists( 'cmb_Meta_Box' ) ) {
                require_once 'init.php';
            }
    
        }
        
        /**
         * Add to buddypress activity timeline. - HOW???
         */
        public function add_activity($post_types) {
    
           /* $activity_id = bp_activity_add( $args );
            
            return $activity_id;*/
    
           /*   $post_types[] = 'file'; 
              return $post_types;*/
        }  
        
    
    } // end class
    
    $uploadForm = new uploadForm();
    
Viewing 18 replies - 1 through 18 (of 18 total)
Skip to toolbar