BuddyDev

Search

[Resolved] "Links xprofile" & NEW PLUGIN

  • Participant
    Level: Master
    Posts: 213
    smart life on #14475

    Hi,

    Can you please support sniped code for “prevent links” in xprofile & limited strings

    Type = Multi-line textare. Limited to 500
    Type = Text box. Limited 100

    WHY:

    1) user add there own website link to advertistment. Remove any words started https, http, www. , something.something (domain.com), something dot something (one word before “dot”, “dot” and one word after “dot”)
    ===> Similar facebook. So far facebook restrict post URL to activity, comment, which is very smart recorgize URL. I tried to post my website URL to post or something, it always auto deleted with message seem spam. I would like to have the same for Xprofile.
    ==> NEW PLUGIN
    If available please also Update one 1 plugin call “Prevent activity post/comment URL, except owner website and some allowed such as google, youtube”

    2) User create a long description, which make website style look ugly.

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #14482

    Hi Julia,
    Please Request/feedback forum for suggesting plugins.

    Also, We do not suggest filtering urls as it will need regular expression and that is not good for performance.

    If you want to limit the length of data a user can enter, I can certainly provide code for that. Please let me know if that is what you need.

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 213
    smart life on #14488

    1) Please give me snipped code for:
    Type = Multi-line textare. Limited to 500
    Type = Text box. Limited 100

    2) Thank you, i will move this topic for plugin suggestion.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #14498

    Here is the code for that

    
    
    /**
     * Limit the allowed no. of characters for xprofile field.
     *
     * @param bool                   $validated is validated?
     * @param string|array           $values value(s).
     * @param BP_XProfile_Field_Type $field field object.
     *
     * @return bool
     */
    function buddydev_limit_xpfield_length( $validated, $values, $field ) {
    	$allowed_len = 0;
    
    	if ( $field instanceof BP_XProfile_Field_Type_Textarea ) {
    		$allowed_len = 500; // how many chars.
    	} elseif ( $field instanceof BP_XProfile_Field_Type_Textbox ) {
    		$allowed_len = 100; 
    	}
    
    	if ( $allowed_len ) {
    		$validated = strlen( $values ) < $allowed_len;
    	}
    
    	return $validated;
    }
    
    add_filter( 'bp_xprofile_field_type_is_valid', 'buddydev_limit_xpfield_length', 10, 3 );
    
    

    It will not show any specific error, just a generic error. Please make sure to specify the length in description.

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 213
    smart life on #14509

    It appear “There was a problem updating some of your profile information. Please try again.” user can’t know what is wrong.

    1) Is there anyway we change this text, if there is wrong come from out of length limited?
    OR
    2) Stop people continue type when reached length, auto cut off the part out of lenghth if people copy/past.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #14533

    Hi Julia,
    That was expected. Specially on the edit page. BuddyPress doe snot give any specific error on the profile edit page. That’s why I asked you to put a message in the description.

    The better and accessible way will need too much code for a simple task like this.

    2. sure, You can use any of the available javascript plugins to do that. I don’t have enough time to find a library and post the code. I will leave it upto you to find and use it.

    Regards
    Brajesh

  • Participant
    Level: Master
    Posts: 213
    smart life on #14557

    Ok thank you.

  • Keymaster
    (BuddyDev Team)
    Posts: 24593
    Brajesh Singh on #14570

    You are welcome.

The topic ‘ [Resolved] "Links xprofile" & NEW PLUGIN’ is closed to new replies.

This topic is: resolved